start packaging

This commit is contained in:
2019-06-25 10:54:07 +01:00
parent 007909891c
commit d7df5736e8
4 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import pytz
import datetime
def string_to_datetime( s ):
if s is None:
return None
try:
return datetime.datetime.strptime( s, "%Y-%m-%dT%H:%M:%S.%fZ" ).replace( tzinfo = pytc.utc )
except ValueError:
return datetime.datetime.strptime( s, "%Y-%m-%dT%H:%M:%SZ" ).replace( tzinfo = pytc.utc )
def datetime_to_string( dt ):
if dt is None:
return None
return dt.astimezone( pytz.utc ).strftime( "%Y-%m-%dT%H:%M:%S.%fZ" )