This file contains hidden or 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 Golang formatting and parsing of | |
// ISO 8601 dates, times, time zones | |
import( | |
"fmt" | |
"time" | |
) | |
loc, _ := time.LoadLocation("America/Los_Angeles") |
This file contains hidden or 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 dates. | |
from datetime import datetime | |
# datetime.strptime() is used to parse iso 8601 strings to | |
# Python datetime.datetime instances. | |
# datetime.strftime() is used to format Python datetime.datetime instances | |
# to ISO 8601 strings. |
This file contains hidden or 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 durations. | |
# A little work is required to navigate between Python's | |
# timedelta syntax and ISO 8601 duration syntax. | |
import re | |
from datetime import datetime | |
from datetime import timedelta |
This file contains hidden or 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 weeks. | |
# The first ISO week of the year is the first week containing | |
# a Thursday. | |
# ISO weeks begin on Monday, with Monday being day 1. | |
from datetime import datetime | |
d = datetime.strptime("2020-W17-7", "%G-W%V-%u") |
This file contains hidden or 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") |
NewerOlder