Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login
iOS 6: Do Not Disturb mode stays on after scheduled time (support.apple.com) similar stories update story
53 points by donohoe | karma 26840 | avg karma 8.73 2013-01-02 13:30:24 | hide | past | favorite | 61 comments



view as:

Noticed this yesterday, it is odd that apple does not catch bugs like this in their qa process.

Programming is hard. Likely they didn't have a test for every possible date.

It seems likely that the fact that this is the 1st of the year is related. This should be an obvious edge condition for testing.

Seems like calendars and time are really hard to get right. The missing December on Android is a good example of that too.

http://arstechnica.com/gadgets/2012/11/december-conspicuousl...


if you're writing tests, you should aim for corner cases. for date-based applications that would include the first and last days in the year, leap years, etc.

programming can be a bit less hard if you learn to do it right.


Good luck enumerating all the edge-case tests for date functions every single time you need a date.


Calendar-based stuff is absurdly difficult to get right. Even if you have something that seems to work you likely have a hidden error somewhere. That's not really an excuse -- edge conditions like DST on/off, and end-of-year should be first on your test list. But calendars suck to work with.

Same here! After missing three calls, I was wondering if I had turned this on by mistake. Glad to see it on front page of HN :)

Literally triggered the day they released an advertisement touting the feature. Embarrassing for anyone, inexcusable for Apple.

I find it fascinating that it doesn't work between 1/1/13 and 1/6/13 but claims it will start working on 1/7/13. What is different about the 7th than the 6th?

It seems significant that this is exactly one week later.

The 7th is the first day of the second week of the year.

So that seems like they're doing some kind of math using the week of year in the calculation- but for what purpose? The UI doesn't seem to give you any options for day of week, just time of day.

Maybe there's code in there that checks day of week but it's hardcoded to run every day to make the UI simpler.


So maybe the service updates it's schedule weekly but the calculation ignores the year. This throws up an error at New Year's and borks the code that would reset when it's toggled on/off?

Maybe they're pushing an update on the 7th

I noticed a bug in another tool today, caused by the week-of-the-year value returned by strftime() returning '00' until the 6th. Possibly related?

It's a not entirely uncommon bug having to do with the naming of the first week of the year. Perhaps it's even as deep as NSCalendar, but I can't check that right now. ref: http://stackoverflow.com/questions/1106943/nscalendar-first-...

Oh yes. The ISO definition is pretty straightforward: «The first week of a year is the week that contains the first Thursday of the year.» (http://en.wikipedia.org/wiki/ISO_week_date)

Actual implementations often look more like this: http://www.epoch-calendar.com/support/getting_iso_week.html

Implementing it as a one-liner would be an interesting code golf exercise.


I fixed the same bug today, it happens when using YYYY instead of yyyy as a dateformat. YYYY is the year of the week the day falls in.

Could you elaborate what exactly is the bug there?

In my case I had a date that I needed to parse from JSON. It was in this format: 2012-01-21. I parsed it using YYYY-MM-dd. It should have been yyyy-MM-dd for the reasons above.

It is not technically a bug but it real easy to get wrong. Perhaps they should have picked sometimg other than YYYY for week years.


I have a hard time (ow) having much anger over time-related bugs these days. Seems the only real way of getting the calendar more programmer-friendly is to switch the world over to Unix time.

I'm amazed by how many applications don't do this (and, similarly, how many languages make it difficult just to get a simple UNIX timestamp). It's far and away the easiest medium to work with, even if you only use it as a pivot format[1].

[1] http://en.wikipedia.org/wiki/Pivot_language


I imagine many things use Unix time or a similarly flat calendar internally (Twitter's Snowflake[0] uses a custom scale), it's the translation into the Gregorian (/Jewish/Mayan/etc) calendar and time scale where the bugs come from. Can't count on 31540000 seconds being a year, time zones, etc.

At the same time, the human brain doesn't seem particularly well-suited to breaking down Unix time into meaningful and reliably consistent scales, so I don't see time getting much easier barring some revolutionary timekeeping system.

[0] https://github.com/twitter/snowflake


Off the top of my head, it's easier to think of APIs that don't provide UNIX timestamps than ones that do. You wouldn't believe some of the half-baked implementations I've seen used in production code (unless you've also had to deal with it yourself, that is!)

Yes, you still have to deal with timezones, but I'd much rather be given a UNIX timestamp for a UTC time and then adjust accordingly, rather than deal with all the other problems that come from communicating and converting between various other calendar formats and locales.

And this exchange should occur at the very last step, only when being displayed to the user. For almost any other purposes, there's no reason that two different applications should need to talk to each other using anything but UNIX timestamps. The potentially error-prone conversion should happen in the latest stage possible, because that's the part with the most knowledge of how any error should be corrected.

> At the same time, the human brain doesn't seem particularly well-suited to breaking down Unix time into meaningful scales,

But we're talking about for programming purposes - to a computer, one 64-bit int is as good as any other.


There is not a 1:1 correspondence between Unix time and UTC. For example, what's the Unix time for 23:59:60 30th June 2012?

> There is not a 1:1 correspondence between Unix time and UTC

Or between any two time formats, but Unix time still makes for the cleanest intermediary by far.


UTC is cleaner than Unix time. Slewing the clock to deal with leap seconds isn't exactly clean.

TAI is even better, though. A steady stream of seconds after an epoch without leap seconds causing complications.


No, it is possible to convert between some time formats. For example, if I invented a new time format that actually was "number of seconds since midnight 1/1/1970" then you could actually convert 1:1 between it and UTC.

It's just that you can't do it with some formats, like UTC - Unix time or UTC - (only include the last 2 digits of the year like in Y2K)


My point is that there's no one format that's going to have seamless conversion with everything that various applications need, but the UNIX timestamp still makes for the best intermediary by far.

There's a difference between "This is not a great time format for conversions" and "This value in the format represents 2 possible different actual times and we have no idea how to tell them apart"

I have seen people store dates in string form, in memory, converting to and from string form as they are updated. It hurts to read code like that.

Instead of telling you about the worst one I've seen in an API implementation, I might as well just show you the code it took to turn it into a correct timestamp:

https://gist.github.com/4438567

(Yes, they gave TWO separate UNIX timestamps, neither of which corresponded to the actual time of interest).


Well, no there are several good cases where storing a time in UTC as seconds since an epoch is wrong.

It's a common mistake.

The first usecase is Birthdays. For most purposes people do not want to store the extract time and date of their birthday in the original time zone. Apple do this, much to my annoyance - it means people's birthdays change as you move around our planet, and that doesn't align with how they work in the real world. If I'm born in Utah on 1/1/1980 it does not mean I celebrate my birthday on 31/12 when I'm in Australia.

The second usecase is recurring meetings, particularly with global participants. The mind bending case is where you have DST in some or all of the TZs. The only remotely correct thing you can do is keep the meeting at the same wall-clock time in the TZ of the meeting owner (9am meeting stays at 9am). Most apps don't, and there is no perfect answer (consider a participant in a different TZ - the meeting changes to a possibly conflicting time).

Sometimes storing the absolute time/date is correct. Other times storing the original UTC offset, as well as the time in UTC is. But most of the time, yes, store it in UTC in whatever form you prefer.


But then we need to do something special for leap seconds. Despite what lots of people think, Unix time is not the number of seconds since 1st Jan 1970, since it doesn't include the 30ish leap seconds that have been added since then.

Quite true. Leap seconds cause an epoch repeat. Most minutes have 60 seconds (0-59), but leap seconds make a 61st second in a minute (0-60).

To be clear: It's not the "correct" wall clock time for most people's day to day use, because it only counts seconds that have elapsed since 1st Jan 1970 00:00 (in a continuous unbroken manner), and does not count leap seconds (which are added to keep our daily-use times in sync with the rotation of the earth.) Isn't time fun?

Since leap seconds are scheduled relatively close to the time that they happen, that's the only way to allow representing future times.

> Seems the only real way of getting the calendar more programmer-friendly is to switch the world over to Unix time.

As others have noted, it'll break during leap seconds where a full second repeats and unix time "conveniently" forgets about it ever existing.


Reminds me of the Zune leap year bug that got some press four years ago [1]. A Zune running during 11:59 PM, Dec 31, 2008 would freeze when the clock ticked over to Jan 1.

Even the response to the problem is similar. Microsoft says, wait until the 2nd and the problem will resolve itself. Apple says, wait until the 7th and the problem will resolve itself.

[1] http://www.pcworld.com/article/156240/microsoft_zune_failure...


When I turn mine off, it knows it isn't supposed to start until 11 PM. Then when I turn it on, it immediately goes on.

So maybe it's using 11 PM yesterday as the trigger instead of 11 PM today.


Turning it on via the switch overrides the Schedule setting. It's not using the prior 11PM, it's using your expressed desire for it to be on.

Always fun: http://infiniteundo.com/post/25326999628/falsehoods-programm.... HN thread: https://news.ycombinator.com/item?id=4128208.

Calendar/time stuff is really, really hard. That's not an excuse for Apple in particular, just that the pitfalls are many and varied to the point where even smart people will screw it up.

I imagine one reason it doesn't seem so hard at first glance is because time and the calendar, in our lived experience, is relatively simple.



So glad it was this because I was starting to wonder if my 18 month old son was playing a prank on me.

Sorry to shoehorn this in: a lot of people use Do Not Disturb mode because they miss calls because they forget to turn off mute.

iPhones need timed mute like Shush! on Android [1] - press mute: it asks "how long?"

Going into the cinema? Mute for two hours. Meeting? An hour.

1. https://play.google.com/store/apps/details?id=com.publicobje...


The biggest favor Apple could do their users is simply to provide a silent ringtone option, so that users can leave their ringer turned off while 'whitelisting' the appropriate contacts.

It's simply staggering that this has apparently never occurred to anyone at Apple. The cheapest feature phone in a bubble package at Radio Shack supports silent ringtones -- or at least it did a few years ago -- but with the iPhone, the user has to record or purchase a track with several seconds of silence and create one manually.


Isn't this kind of what Do Not Disturb was hoping to do, with the whitelisting?

That is exactly what Do Not Disturb does. It allows for whitelisting of contacts, both specifically in the Contacts app, and if they are very persistent callers (emergency, urgent).

ooh ooh ooh. Disclaimer: Plug for my app called "tonepush" coming up.

I wrote an app that allows you to change the ringtone on someone else's phone (think xmas tunes, valentine songs etc etc). Anyway, one of my users had this issue where his wife is expecting a kid and he always has his phone on silent at work, so I've extended the app so that if he enables a web password, she can log in, turn his phone off silent and then ring him.

Before you say it, no it's not for iPhone but for Android. It's called TonePush Beta. All feedback gratefully received.


Interestingly you can set a silent alert for text messages per contact. I have this for automated balance/credit/debit alerts from my banks as they seem to think everyone wants to know their balance at 7am.

Yeah, AT&T likes to sending texts to confirm my monthly payment at the ungodly hour of 2 PM. For some reason, these idiots assume that everybody works 9-5 and nobody works nights.

4.2 also has "do not disturb" mode. It works properly too!

Could have been spun as a feature. Apple believes you should be on a break during this time of the year so DND stays on until the 7th. Because we believe in choice, you can still switch it off manually.

Okay maybe not.


Legal | privacy