8 ms·
Why is subtracting these two times in 1927 giving a strange result? (2011)
- bartvk 6y agoI love this kind of stuff. For example the date of October 6th, 1582 doesn't exist. https://blog.yossarian.net/2015/06/09/Dates-That-Dont-Exist https://blog.yossarian.net/2015/06/09/Dates-That-Dont-Exist
- lohfu 6y agoin most countries the dates 6th - 14th october 1582 existed since far from all countries switched to the Gregorian calendar when the Papal bull to switch was issued. Essentially only Catholic countries followed the bulla. Russia, for example, didnt switch from the Julian calendar until 1917.
- dahart 6y agoThat’s pretty interesting. So is Ruby’s behavior - calling the date invalid - is that bad behavior, or a totally reasonable choice to assume the DateTime is Gregorian? It would be neat if the exception said why the date was invalid, but I guess for any dates going back in history globally we should try to use a more sophisticated time lib that takes calendar and locale into account whenever they exist.
- tangus 6y agoIt's documented. >A Date object can be created with an optional argument, the day of calendar reform as a Julian day number, which should be 2298874 to 2426355 or negative/positive infinity. The default value is Date::ITALY (2299161=1582-10-15).
- jcranmer 6y agoThe Gregorian calendar was adopted in arguably four main spurts. The first spurt changed over in 1582, and was exclusively Catholic countries. Most of Protestant Europe then changed in 1700, in a second spurt. The third spurt was the Anglosphere, switching in 1752, and Sweden, switching for good in 1753. The final spurt was Orthodox countries changing over during and after World War I. There is an additional wrinkle to comment on, which is that not every country started their year on January 1. And when a country changed their year start to January 1 is often not the same as when they changed from Julian to Gregorian. In the absence of more specific information, it is usual to assume that an unlabeled calendar reference is a Julian date reference (starting on January 1) until October 4, 1582 and a Gregorian date reference from October 15, 1582 onwards, with October 5-14, 1582 not existing. It should be noted that this calendar does not correspond to any actual calendar used by any polity in actual history that I am aware of, but it would tend to be less confusing than actual historical calendars.
- rmah 6y agoWhat about non-european cultures? When was the Gregorian calendar adopted generally in india, central asia, the far east (china, japan, korea), south-east asia, east africa, west africa?
- jcranmer 6y agoEast Asia adopted the Gregorian calendar as part of the drives to Westernization: Japan in 1873, Korea in 1895, and China in the early 20th century (post-Qing China wasn't a unified country following the same rules). In the Americas, the Julian or Gregorian calendar would have been adopted at time of European conquest. Similarly, in most of the rest of the world (which was conquered by Europeans at some time or another), civil administration would have switched to Gregorian when Europeans started administration, although this might not imply a change in local usage of calendar. Islamic countries have had the most resistance to the Gregorian calendar, with Saudi Arabia not using it (de jure, although it was used in private industry de facto) until 2016 and Iran and Afghanistan still not using it.
- mehrzad 6y agoIran uses its own observation-based solar calendar (which means it follows the seasons exactly every year), but it also reports the Gregorian date on the nightly news. People in Iran are generally aware of the Gregorian month and year they are in, if not the exact date.
- deleted 6y ago[deleted]
- esrauch 6y agoI would have presumed the perceived gap was "yesterday we were using Julian, today we'll use Gregorian" (or Gregorian v0 to v1). Instead the article suggests it is "before today Julian and Gregorian both existed and were the same, now Gregorian has jumped".
- elliekelly 6y agoTime is one of those weird things I didn’t give much thought to until I started programming. And in the beginning it annoyed me that something as “simple” as time could be so complicated for computers. But then I read stories like this and I try to imagine how we’d deal with these complexities if they hadn’t been fixed before things got so complicated. What would happen if we told the world in 2020 that we’re just going to skip ten days ahead on the calendar? How many things would break? I suspect a whole lot.
- bartvk 6y agoYup, me too. I thought I figured it out, until I started builing apps for an airline. Cabin crew wish to view their schedules in local times when departing and arriving. It took several tries to show their schedule in a calendar-like view that intuitively made sense to them.
- lisper 6y agoIt's not just airline crews. I do a lot of traveling, and I want to enter my itinerary in my calendar in terms of the local time where I will be at the time of the event. I use a Mac, and Mac calendar assumes that all times are local to the time zone I'm in when I entered the event. So when I'm on the road, I would like to change the time zone on my laptop to match the local time where I am, but I can't because if I do, Calendar will move every event on my calendar to a new (wrong) time. So I have to keep my Mac's time zone set to my home time zone in order to not have it screw up my calendar. It drive me nuts.
- rkagerer 6y agoSamoa is near the international date line and flipped back and forth a couple times to align with whoever it was doing more trading with at the time (Asia or US). In 1892 they celebrated 4th of July (US independence day) twice.
- yread 6y agoWouldn't you hit strange results doing this much earlier - there are leap seconds (or worse) every few years
- rkagerer 6y agoThe suggestions to use UTC are good, but that doesn't completely immunize you from all the weirdness of time. e.g. UTC still has leap seconds kludged in from time to time "because the Earth's rotation speed varies in response to climatic and geological events" [1]. There's been talk of redefining it at some point to remove them. GPS Time or Precision Time Protocol may be suitable when you need to measure events on a continuous scale. Leap smeared time used by Google and AWS is also an interesting topic [2]. [1] https://en.m.wikipedia.org/wiki/Leap_second https://en.m.wikipedia.org/wiki/Leap_second [2] https://developers.google.com/time/smear https://developers.google.com/time/smear
- dahart 6y agoApparently days are slightly longer now (up to 0.06 microseconds) just in the last 10 year because of the enormous dam in China. 1 leap second every 16M years, I wonder if that’s enough to care about right now? https://en.wikipedia.org/wiki/Three_Gorges_Dam#Terrestrial_impact https://en.wikipedia.org/wiki/Three_Gorges_Dam#Terrestrial_i... Time smear is an interesting concept. Once enough of the world’s clocks are synced to online sources, I wonder if we should consider using that kind of idea to smear away daylight savings time over the whole year. Not sure it’s a great idea, but maybe it would be possible to set the sunrise to be 7am every day.
- fanf2 6y agoOne of the earlier proposals for DST suggested shifting by 20 minutes four times in spring and back four times in autumn. Counting hours from sunrise or sunset (instead of noon) was common in the ancient world. (They were often rubber hours so there were always 12 hours of day and 12 of night regardless of the season.) Some years ago I sketched a way to do smoothed DST based on when the sun rises. The trick is to avoid time zone differences due to differences in latitude (as well as longitude). I chose to use sunrise at the nearest tropic as the benchmark, which gives you a gradual DST adjustment of about an hour and a half between winter and summer, changing by up to a minute or two each day. http://catless.ncl.ac.uk/Risks/search?query=Sunrise+time+Finch http://catless.ncl.ac.uk/Risks/search?query=Sunrise+time+Fin...
- floitsch 6y agoI implemented (part of) the Dart date/time library. Lots of fun stuff with time zones... Wrote a blog post about the most interesting things I found: https://medium.com/@florian_32814/date-time-526a4f86badb https://medium.com/@florian_32814/date-time-526a4f86badb
- lultimouomo 6y agoYou read the question, you immediately know Jon Skeet is giving the answer.
- mark-r 6y agoThat's a perfect example of why Jon Skeet is untouchable in Stack Overflow reputation.
- lordnacho 6y agoTime is one of those libs that you don't try to implement on your own. It's one of those things that sound simple on the face of it, but you soon find out there's a huge number of complications. Things like locales having different daylight savings, which require a DB to keep track of, and might change in the future. Historically baked in weirdness like the thing in this SO answer. The international dateline. Arizona having its own TZ. Half hour countries. Cultural specific calendars like Jewish or Arab. It's a cave of horrors. At best, try to understand that if you do use something other than epoch time, you might have to record a bunch of stuff like what I mentioned.
- ben-schaaf 6y agoComputerphile has a great video on this: https://www.youtube.com/watch?v=-5wpm-gesOY https://www.youtube.com/watch?v=-5wpm-gesOY
- moomin 6y agoThe fun thing about this is that just from the headline I knew who would have the highest rated and extremely complete answer.
- daveslash 6y agoTwo other interesting pieces of Time Trivia: 1. The date 30 December 2009 never existed in Somoa and Tokelau https://www.bbc.com/news/world-asia-16351377 https://www.bbc.com/news/world-asia-16351377 2. Until 1937, the Netherlands Timezone was a nice, even, GMT + 00:19:32.13 -- yes, the timezone offset was to a hundredth of a second. https://en.wikipedia.org/wiki/UTC%2B00:20 https://en.wikipedia.org/wiki/UTC%2B00:20