Skip to content

Commit

Permalink
Fix another Daylight Saving Time bug. Fix initial AM/PM state of edit…
Browse files Browse the repository at this point in the history
…ed alarm. (#88)

* That bug fix in 3.4.1? Turns out an alarm going off on the _same day_ clocks are changed could go off at the wrong time, not merely be displayed incorrectly. That's fixed now too.
* Fix initial AM/PM state of edited alarm.
  • Loading branch information
kshetline authored Nov 7, 2022
1 parent 95d569b commit 08c1fc5
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 3.4.2

* That bug fix in 3.4.1? Turns out an alarm going off on the _same day_ clocks are changed could go off at the wrong time, not merely be displayed incorrectly. That's fixed now too.
* Fix initial AM/PM state of edited alarm.

## 3.4.1

* Fix a Daylight Saving Time bug that caused the displayed time for an upcoming alarm the day after a clock change to be off by an hour. (This self-corrected after midnight, and did not affect when the alarm actually went off.)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aw-clock",
"version": "3.4.1",
"version": "3.4.2",
"license": "MIT",
"author": "Kerry Shetline <[email protected]>",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions sass/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sass/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aw-clock-sass",
"version": "3.4.1",
"version": "3.4.2",
"description": "SASS builder for aw-clock",
"keywords": [
"sass"
Expand Down
4 changes: 2 additions & 2 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aw-clock-server",
"version": "3.4.1",
"version": "3.4.2",
"license": "MIT",
"author": "Kerry Shetline <[email protected]>",
"private": true,
Expand Down
18 changes: 12 additions & 6 deletions src/alarm-monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ export class AlarmMonitor {
let updatePrefs = false;
const now = new DateTime(alarmCheckTime, this.appService.timezone);
const minutesInDay = now.getMinutesInDay();
const wt = now.wallTime;
const midnight = new DateTime([wt.y, wt.m, wt.d, 0, 0, 0], this.appService.timezone);
const nowMinutes = floor(now.utcSeconds / 60);
const newActiveAlarms = [];
let sound = '';
Expand All @@ -78,10 +76,18 @@ export class AlarmMonitor {

if (snoozed)
alarmTime = snoozed.restartAt;
else if (isDaily)
alarmTime = floor(midnight.utcSeconds / 60) + alarmTime;
else
alarmTime -= floor(now.utcOffsetSeconds / 60);
else if (isDaily) {
const wt = now.wallTime;
const alarmDT = new DateTime([wt.y, wt.m, wt.d, floor(alarmTime / 60), alarmTime % 60], this.appService.timezone);

alarmTime = floor(alarmDT.utcSeconds / 60);
}
else {
const wt = new DateTime(alarmTime * 60000, 'UTC').wallTime;
const alarmDT = new DateTime([wt.y, wt.m, wt.d, wt.hrs, wt.min], this.appService.timezone);

alarmTime = floor(alarmDT.utcSeconds / 60);
}

if (!snoozed) {
if (!isDaily && alarmTime < nowMinutes - 65 && processMillis() > this.startTime + 60000) { // Expired alarm?
Expand Down
5 changes: 3 additions & 2 deletions src/settings-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ export class SettingsDialog {
this.dayOfWeekPanel.css('display', daily ? 'flex' : 'none');
this.alarmHour.val(time.substring(0, 2));
this.alarmMinute.val(time.substring(3, 5));
this.alarmMeridiem.val(time.substring(7, 8));
this.alarmMeridiem.val(time.substring(6, 7));
this.alarmAudio.val(alarm.sound);
this.alarmMessage.val(alarm.message);

Expand Down Expand Up @@ -1089,7 +1089,8 @@ export class SettingsDialog {
this.alarmDelete.prop('disabled', true);
this.alarmEdit.prop('disabled', true);
this.clearAlarmTime();
this.renderAlarmList(this.newAlarms);
this.renderAlarmList([]);
setTimeout(() => this.renderAlarmList(this.newAlarms));

this.renderAlertFilterList(previousSettings.alertFilters);

Expand Down

0 comments on commit 08c1fc5

Please sign in to comment.