Skip to content

How to parse and format ISO-8601 #2

@ghost

Description

I'm excited to use this library, as I suspect it may help with many of my Emacs datetime issues. I had a couple questions about how to make some transformations, and I'm hoping you might be willing to help.

  1. One common scenario is I have a timestamp like this and I want to get the UTC version:
>>> ts = "2018-06-12T22:10:00+03:00"
>>> pendulum.parse(ts).in_tz('UTC').to_iso8601_string()
'2018-06-12T19:10:00Z'
  1. Or I have an org-mode format string and I want the ISO format.
>>> ts = "[2018-06-12 Tue 22:10]"
>>> pendulum.from_format(ts, "[YYYY-MM-DD ddd HH:mm]", tz='America/New_York'
    ).to_iso8601_string()
'2018-06-12T22:10:00-04:00'

I couldn't figure out how to do these in datetime.el. Would you be willing to show how to do this, if that functionality is available? Thanks very much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions