While adding support for ISO 8601 date/time strings to Flask-RESTful I was struggling with all that hated Python timezone stuff, specifically with the need to convert a datetime object to UTC timezone. With the libraries that Flask-RESTful was already using this solution looked the easiest:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
UPD
Actually there is a much cleaner way to do the same, using exclusively pytz
:
1 2 3 4 5 6 7 8 9 |
|