Last active
May 12, 2020 15:57
-
-
Save spatialtime/7cd5c9ea974617369a96325d951ef755 to your computer and use it in GitHub Desktop.
Pythonic formatting and parsing of ISO 8601 ordinal dates.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This snippet demonstrates Pythonic formatting and parsing of | |
# ISO 8601 ordinal dates (4-digit year + "-" + ordinal day). | |
# Note: an ordinal day in this context is the nth day of | |
# the year, with Jan 1 being ordinal day 1 and Dec 31 | |
# of non-leap year (a "common year") being day 365. | |
from datetime import datetime | |
d = datetime.strptime("2020-355", "%Y-%j") | |
print(format(d, "%Y-%j")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment