Fix Scheduled Hour Time Zone Conversion

Created on 23 October 2024, about 2 months ago

When the scheduled time for the bulk email is set, a conversion is done to change from the user's time zone to UTC before saving the hour. When going from another time zone back to UTC the offset should be removed instead of being added in again.

<!--break-->

The conversion is accomplished with:

public function setScheduledHour($num) {
  $now = $this->time->getRequestTime();
  $offset = (strtotime('UTC', $now) - $now) / 3600;
  $this->configuration['scheduled_time'] = ($num + $offset + 24) % 24;
}

The offset is correct, but the problem is the conversion is going in the wrong direction. Using 16 EDT as an example, setScheduledHour(16) returns 12 UTC when it should be 20 UTC.

This could be corrected by changing

$this->configuration['scheduled_time'] = ($num + $offset + 24) % 24;

to

$this->configuration['scheduled_time'] = ($num - $offset + 24) % 24;

That way the offset is removed when saving the hour in UTC. The getScheduledHour() should be adjusted in a similar way to add the offset back to show the hour in the user's time zone.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States glassb

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024