Enabling alarm after midnight schedules it for the next day

Bug #1442518 reported by Philippe Vaucher on 2015-04-10
38
This bug affects 8 people
Affects Status Importance Assigned to Milestone
Ubuntu Clock App
High
themeles

Bug Description

If it's past midnight, and you enable one of your saved alarm, it won't ring on the same day but the day after that.

For example:

- It's 01h30 in the night.
- You enable your saved alarm which is at 06h30
- The widget shows "In 29h" instead of "In 5h"

Steps to almost reliably reproduce the bug:
1. Create an alarm for 10:00 AM and disable it
2. Close clock app
3. Manually change the system date to the next day and also set the time as 01:00 AM (any time before 10:00 AM)
4. Open clock app
5. Enable alarm created in step 1

At the point when the alarm is enabled it should show that the alarm is schedule to ring for today and not tomorrow.

Related branches

Joni Arida (joni-arida) on 2015-04-17
Changed in ubuntu-clock-app:
status: New → Confirmed

Hum, it's weird because the code *looks* correct:

```
    function _get_next_active_alarm(alarmModel, clockTime) {
        var activeAlarmDate = undefined

        for (var i=0; i<alarmModel.count; i++) {
            var currentAlarm = alarmModel.get(i)
            if (currentAlarm.enabled && currentAlarm.date > clockTime) {
                if (activeAlarmDate === undefined ||
                        currentAlarm.date < activeAlarmDate) {
                    activeAlarmDate = currentAlarm.date
                }
            }
        }

        return activeAlarmDate
    }
```

Changed in ubuntu-clock-app:
importance: Undecided → High
milestone: none → 3.3
Joni Arida (joni-arida) wrote :

When you switch on the alarm it is written he will ring in more the one day. I add a screenshot to thos comment!

themeles (themeles) wrote :

Exactly the same issue here.

Torsten Sachse (torsten-sachse) wrote :

I am suffering from the same issue which happens to me every day. Version 3.3.192 on a BQ on r22.

themeles (themeles) wrote :

I just did some test. I set my timezone to Senegal (=UTC), set the time to 00:48 and then I went to the Alarm clock and activated all my alarms. The resut:
08:30 Alarm passed
06:47 Alarm passed
06:10 Alarm passed
06:20 Alarm passed
07:10 1 day 6 hours and 21 minutes
07:35 1 day 6 hours and 46 minutes
07:00 1 day 6 hours and 10 minutes

none of them were set correctly. And none has a limitation to a certain day.

themeles (themeles) wrote :

I was messing around with this bug again and I found the following rule:
* Alarm created on the 1st of the month -> OK
* Alarm set again (just with the switch) on the 2nd -> ERROR
* Alarm set again (just with the switch) on the 3rd -> OK if it has been activated with the switch on the 2nd
* Alarm set again (just with the switch) on the 5th (!) -> ERROR, because it has not been activated on the 4th
* Alarm set again (just with the switch) on the 5th (!) -> ERROR ("Alarm passed")

I think this issue could be fixed if the date is set to undefined as soon as the alarm gets deactivated.

Changed in ubuntu-clock-app:
status: Confirmed → In Progress
assignee: nobody → Nekhelesh Ramananthan (nik90)
Nekhelesh Ramananthan (nik90) wrote :

@users who are affected by this bug, we might have a potential fix thanks to the help of themeles. Please help us validate the fix.

Steps to test:
1. Download the click package attached to this comment
2. Connect your 15.04 vivid phone to the computer.
3. Push the click package from your computer to the phone by running, " adb push com.ubuntu.clock_3.3._armhf.click /tmp " without the quotes
4. Install click package by running, " pkcon install-local --allow-untrusted /tmp/com.ubuntu.clock_3.3._armhf.click"
5. Test if it fixes the bug.

Thanks for your help.

Changed in ubuntu-clock-app:
assignee: Nekhelesh Ramananthan (nik90) → themeles (themeles)

Fix committed into lp:ubuntu-clock-app at revision 279, scheduled for release in ubuntu-clock-app, milestone 3.3

Changed in ubuntu-clock-app:
status: In Progress → Fix Committed
description: updated
Changed in ubuntu-clock-app:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers