Merge pull request #13 from Neradoc/patch-1

Fix example from the readme for Circuitpython
This commit is contained in:
Dan Halbert 2021-10-30 17:42:08 -04:00 committed by GitHub
commit e9ae7cd782
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -62,7 +62,7 @@ Usage Example
# Example of working with a `datetime` object
# from https://docs.python.org/3/library/datetime.html#examples-of-usage-datetime
from adafruit_datetime import datetime, date, time, timezone
from adafruit_datetime import datetime, date, time
# Using datetime.combine()
d = date(2005, 7, 14)
@ -72,7 +72,6 @@ Usage Example
# Using datetime.now()
print("Current time (GMT +1):", datetime.now())
print("Current UTC time: ", datetime.now(timezone.utc))
# Using datetime.timetuple() to get tuple of all attributes
dt = datetime(2006, 11, 21, 16, 30)
@ -80,12 +79,13 @@ Usage Example
for it in tt:
print(it)
# Formatting a datetime
print(
"The {1} is {0:%d}, the {2} is {0:%B}, the {3} is {0:%I:%M%p}.".format(
dt, "day", "month", "time"
)
)
print("Today is: ", dt.ctime())
iso_date_string = "2020-04-05T05:04:45.752301"
print("Creating new datetime from ISO Date:", iso_date_string)
isodate = datetime.fromisoformat(iso_date_string)
print("Formatted back out as ISO Date: ", isodate.isoformat())
Documentation
=============