@@ -62,7 +62,7 @@ Usage Example
62
62
63
63
# Example of working with a `datetime` object
64
64
# from https://docs.python.org/3/library/datetime.html#examples-of-usage-datetime
65
- from adafruit_datetime import datetime, date, time, timezone
65
+ from adafruit_datetime import datetime, date, time
66
66
67
67
# Using datetime.combine()
68
68
d = date(2005 , 7 , 14 )
@@ -72,20 +72,20 @@ Usage Example
72
72
73
73
# Using datetime.now()
74
74
print (" Current time (GMT +1):" , datetime.now())
75
- print (" Current UTC time: " , datetime.now(timezone.utc))
76
75
77
76
# Using datetime.timetuple() to get tuple of all attributes
78
77
dt = datetime(2006 , 11 , 21 , 16 , 30 )
79
78
tt = dt.timetuple()
80
79
for it in tt:
81
80
print (it)
82
81
83
- # Formatting a datetime
84
- print (
85
- " The {1} is {0: %d} , the {2} is {0: %B} , the {3} is {0: %I:%M%p} ." .format(
86
- dt, " day" , " month" , " time"
87
- )
88
- )
82
+ print (" Today is: " , dt.ctime())
83
+
84
+ iso_date_string = " 2020-04-05T05:04:45.752301"
85
+ print (" Creating new datetime from ISO Date:" , iso_date_string)
86
+ isodate = datetime.fromisoformat(iso_date_string)
87
+ print (" Formatted back out as ISO Date: " , isodate.isoformat())
88
+
89
89
90
90
Documentation
91
91
=============
0 commit comments