mirror of https://github.com/snachodog/mybuddy.git
Handle utc offset changes (daylight savings) in the Sleep Patterns graph.
This change simply adjusts the size of the bar in the graph if an offset change happened between a sleep entry's start and end date.
This commit is contained in:
parent
e2733e6b1e
commit
490e07c381
|
@ -95,6 +95,13 @@ def sleep_pattern(instances):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Update the previous entry duration if an offset change occurred.
|
||||||
|
# This can happen when an entry crosses a daylight savings time change.
|
||||||
|
if start_time.utcoffset() != end_time.utcoffset():
|
||||||
|
diff = start_time.utcoffset() - end_time.utcoffset()
|
||||||
|
duration -= timezone.timedelta(seconds=diff.seconds)
|
||||||
|
y_df.set_value(df_index - 1, start_date, duration.seconds/60)
|
||||||
|
|
||||||
last_end_time = end_time
|
last_end_time = end_time
|
||||||
|
|
||||||
dates = list(y_df)
|
dates = list(y_df)
|
||||||
|
|
Loading…
Reference in New Issue