Fix daylight savings bug when cloning schedule from previous week

This commit is contained in:
Lance Edgar 2017-02-21 13:57:04 -06:00
parent 75c73aad13
commit 59799302bd

View file

@ -169,11 +169,20 @@ class ScheduleView(TimeSheetView):
.filter(model.ScheduledShift.start_time >= make_utc(start_time))\
.filter(model.ScheduledShift.end_time < make_utc(end_time))
for shift in shifts:
# must calculate new times using date as base, b/c of daylight savings
start_time = localtime(self.rattail_config, shift.start_time, from_utc=True)
start_time = datetime.datetime.combine(start_time.date() + offset, start_time.time())
start_time = localtime(self.rattail_config, start_time)
end_time = localtime(self.rattail_config, shift.end_time, from_utc=True)
end_time = datetime.datetime.combine(end_time.date() + offset, end_time.time())
end_time = localtime(self.rattail_config, end_time)
Session.add(model.ScheduledShift(
employee_uuid=shift.employee_uuid,
store_uuid=shift.store_uuid,
start_time=shift.start_time + offset,
end_time=shift.end_time + offset,
start_time=make_utc(start_time),
end_time=make_utc(end_time),
))
copied += 1