Fix daylight savings bug when cloning schedule from previous week
This commit is contained in:
parent
75c73aad13
commit
59799302bd
|
@ -169,11 +169,20 @@ class ScheduleView(TimeSheetView):
|
||||||
.filter(model.ScheduledShift.start_time >= make_utc(start_time))\
|
.filter(model.ScheduledShift.start_time >= make_utc(start_time))\
|
||||||
.filter(model.ScheduledShift.end_time < make_utc(end_time))
|
.filter(model.ScheduledShift.end_time < make_utc(end_time))
|
||||||
for shift in shifts:
|
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(
|
Session.add(model.ScheduledShift(
|
||||||
employee_uuid=shift.employee_uuid,
|
employee_uuid=shift.employee_uuid,
|
||||||
store_uuid=shift.store_uuid,
|
store_uuid=shift.store_uuid,
|
||||||
start_time=shift.start_time + offset,
|
start_time=make_utc(start_time),
|
||||||
end_time=shift.end_time + offset,
|
end_time=make_utc(end_time),
|
||||||
))
|
))
|
||||||
copied += 1
|
copied += 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue