To do the actual date comparison so that the time component is ignored, I’m using the rather handy would be 1, since today is closest to, well, today.
However, if you run the above code in an Xcode Playground somewhere in the GMT timezone whilst DST is in effect you will see that the result is 2.
Comparing dates is one of the most common things you have to do as a developer of almost any type of software. I’m going to highlight just one issue that recently caused an embarassing bug in my app Memories.
At first glance it would seem to be something almost trivially easy. It involved just a simple date comparison, ignoring time, and without crossing timezones.
The following playground should make everything clear (note that the values shown in comments are values I obtained running in the GMT timezone with DST in effect late on April 24th 2016): The ordinal day number for internally stores dates in UTC, which is the same as GMT for most purposes.