Skip to content

Commit

Permalink
Merge branch 'xiangnandang-master'
Browse files Browse the repository at this point in the history
Accepting Xiangnan Dang pull request to address timeZone argument for check_daylight_savings_crossover function in summariseEpoch.py
  • Loading branch information
aidendoherty committed Jun 9, 2020
2 parents d12b33e + c4d730b commit 58c677c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions accelerometer/summariseEpoch.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def check_daylight_savings_crossover(e, startTime, endTime, summary,
"""

daylightSavingsCrossover = 0
utc_tz = pytz.timezone("UTC")
localTime = pytz.timezone(timeZone)
# Convert because pytz can error if not using python datetime type
startTimeZone = localTime.localize(startTime.to_pydatetime())
Expand All @@ -218,11 +219,14 @@ def check_daylight_savings_crossover(e, startTime, endTime, summary,
for t in localTime._utc_transition_times:
if t>startTime:
transition = t
transition = transition - pd.DateOffset(seconds = 1)
transition = utc_tz.localize(transition)
transition = localTime.normalize(transition)
transition = transition.replace(tzinfo = None)
transition = transition + pd.DateOffset(seconds = 1)
break
# If Autumn crossover time, adjust transition time plus remove 1hr chunk
if offset == -1:
# pytz stores dst crossover at 1am, but clocks change at 2am local
transition = transition + pd.DateOffset(hours=1)
# Remove last hr before DST cut, which will be subsequently overwritten
e = e[(e.index < transition - pd.DateOffset(hours=1)) |
(e.index >= transition)]
Expand Down

0 comments on commit 58c677c

Please sign in to comment.