[FIX] hr_effective_attendance_period: DST

daylight saving time (DST) fix when compute UTC time
This commit is contained in:
clementthomas
2023-04-13 08:30:46 +02:00
parent 070bdaca52
commit c7f2d0683b
2 changed files with 4 additions and 3 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*.*~
*.pyc

View File

@@ -43,9 +43,8 @@ class ResourceCalendar(models.Model):
return morning_worked and afternoon_worked return morning_worked and afternoon_worked
def _compute_datetime_in_utc_tz(self, date): def _compute_datetime_in_utc_tz(self, date):
dt_now = datetime.now(pytz.timezone(self.env.context.get('tz', 'utc') or 'utc')) user_tz = pytz.timezone(self.env.context.get('tz', 'utc') or 'utc')
utc_date = date - dt_now.utcoffset() return user_tz.localize(date).astimezone(pytz.utc)
return utc_date
def _is_worked_attendance(self, resource, day, attendance): def _is_worked_attendance(self, resource, day, attendance):
attendance_start = fields.Datetime.to_datetime(day.date()) + timedelta(hours=attendance.hour_from) attendance_start = fields.Datetime.to_datetime(day.date()) + timedelta(hours=attendance.hour_from)