pytz peut normaliser les dates
* En gros, si tz=Europe/Paris, et que le temps est localisé à utc+0100 alors que la date référencée est en avril, on pousse à utc+0200.
This commit is contained in:
parent
55dadbd693
commit
d6f4e7aefd
1 changed files with 2 additions and 0 deletions
|
@ -355,6 +355,7 @@ def datetime_from_generalized_time_format(gtf):
|
|||
tz_dict = build_tz_dict()
|
||||
the_timezone = tz_dict.get(tz, pytz.utc)
|
||||
the_date = the_timezone.localize(the_date)
|
||||
the_date = the_timezone.normalize(the_date)
|
||||
return the_date
|
||||
|
||||
def datetime_to_generalized_time_format(datetime_obj):
|
||||
|
@ -363,6 +364,7 @@ def datetime_to_generalized_time_format(datetime_obj):
|
|||
if datetime_obj.utcoffset() is None:
|
||||
if pytz is not None:
|
||||
datetime_obj = pytz.utc.localize(datetime_obj)
|
||||
datetime_obj = pytz.utc.normalize(datetime_obj)
|
||||
else:
|
||||
to_append = "Z"
|
||||
mostly_gtf = datetime.datetime.strftime(datetime_obj, "%Y%m%d%H%M%S%z")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue