Back to News
Advertisement
Advertisement

⚡ Community Insights

Discussion Sentiment

75% Positive

Analyzed from 2905 words in the discussion.

Trending Topics

#calendar#gregorian#date#dates#julian#https#datetime#using#days#org

Discussion (49 Comments)Read Original on HackerNews

autarchabout 2 hours ago
I'm the author of the Perl DateTime library. It works correctly as _documented_. Here's the first two paragraphs of the docs:

> DateTime is a class for the representation of date/time combinations, and is part of the Perl DateTime project.

> It represents the Gregorian calendar, extended backwards in time before its creation (in 1582). This is sometimes known as the "proleptic Gregorian calendar". In this calendar, the first day of the calendar (the epoch), is the first day of year 1, which corresponds to the date which was (incorrectly) believed to be the birth of Jesus Christ

Always RTFM.

Edit: I double-checked, and while this was not in the docs in the first release, it _was_ in the docs as of 2015.

https://metacpan.org/pod/DateTime

dinkelbergabout 1 hour ago
Who else uses the proleptic Gregorian calendar other than programmers of datetime libraries?
tshaddoxabout 1 hour ago
It's typically not used in modern historical writing when referring to events located in areas that used the Julian calendar at that time.

But it is typically used when referring to events located in areas with no calendar system familiar to modern readers, most notably the Maya calendar. Maya Long Count dates are typically converted to the proleptic Gregorian calendar.

Also, many modern historical writings will display both Julian and Gregorian dates, particularly for dates around when the calendars were changing or when context is unclear (e.g. a historical figure who was born in an area with one calendar and died in an area with another calendar).

bloppeabout 1 hour ago
Considering it only diverges from the standard Gregorian for dates more than 400 years ago, it's not super relevant. Most people don't think about it. But it made a lot of sense to do the shift at the time. All recorded dates up to that point had been physically written down, so it would have been infeasible to migrate those all to the proleptic. If computers had been around, maybe things would have been different.

Fun fact: Greece was still using the old Julian calendar as of 1928, so it's entirely possible that you'll see dates on relatively recent Greek documents that are up to 14 days off from the calendar the rest of the world was using. Civil timekeeping is just a mess.

autarchabout 1 hour ago
Who writes computer programs that deal with pre-1582 _dates_ at all?

In science-related code, I can image a case for calculating things like seconds elapsed across a very long time period. But in that case you're not really dealing with dates. Instead, you want something like the Unix epoch, but probably with an earlier epoch start.

There may be some very niche cases for pre-1582 dates in code that I'm not thinking of. But I'd expect that in this case you're going to put a lot of effort into finding the right libraries, or you might just write your own code.

Regardless, the linked blog post says of DateTime: "Unfortunately, like Python, a proper error message for impossible Gregorian dates is notably absent."

But this is just wrong. There's no "proper error message" to emit. The code works as documented.

bloppeabout 1 hour ago
Most applications don't have to worry about it, but platforms do. The SQL standard requires accurate date representation for years 0000-9999. I was surprised to learn about the Gregorian shift while testing our database system. I also learned about "war time" in WW2 and the "battle of the clocks" in colonial India. A lot of history came out of debugging those tests.
tshaddoxabout 1 hour ago
> Who writes computer programs that deal with pre-1582 _dates_ at all?

People writing knowledge base software, like Wikidata. It's helpful to be able to display historical dates in any desired calendar, and also to be able to do date arithmetic between any two arbitrary dates.

deathanatosabout 1 hour ago
> In essence, then, those ten days in 1582 never happened and simply do not exist within the Gregorian calendar system used almost universally in the West today.

I find these things so much easier to think about if you consider the change as a change from one calendar system to another calendar system. Those 10 days certainly exist, in both calendar systems, they just represent different points in time. I.e., I think it's easier to just consider both calendar systems as the rules, extended forward & backwards infinitely ("proleptic"). Some people switched from a Julian calendar to a Gregorian one in 1582.

"Some people did not experience days with these labels in some areas of the world" … I get where it's coming from, but it's not how I'd build a library.

If you worry about the switch, then you have to ask "which switch?" which TFA only lightly touches on. The 1582 one is famous, of course, but not everyone switched, and other parts of the worlds switched as time went on, to as late as 1918, when Russia switched.[1] (And you can see other messiness in that table, too.)

Needing to deal with it is niche enough that I think most language std libs should implement the proleptic Gregorian calendar, and let an application whose niche requires it deal with the switch (& whichever switch it requires).

[1] https://en.wikipedia.org/wiki/List_of_adoption_dates_of_the_...

sixtyj32 minutes ago
Messiness is an understatement :)

Thanks. I haven’t known that countries switched in different years.

Gregorian calendar is just one piece.

https://en.wikipedia.org/wiki/Civil_calendar

Eighteen countries use another calendar alongside the Gregorian calendar…

woodruffwabout 2 hours ago
It’s funny to see this on HN. I wrote this 11 years ago as an undergraduate.

The afternotes at the end of the post are worth reading; people have sent me various qualifications and corrections over the years.

SoftTalkerabout 2 hours ago
There seems to be disagreement about the year. Two systems I checked assume 1752, not 1582.

(OpenBSD)

  $ man cal
  [...]
  The Gregorian Reformation is assumed to have occurred in
  1752 after the 2nd of September.  By this time, most
  countries had recognized the Reformation (although a few
  did not recognize it until the early 1900s). Eleven days
  following that date were eliminated by the Reformation, so
  the calendar for that month is a bit unusual.
(Ubuntu Linux)

  [...]
  -s country_code
      Assume the switch from Julian to Gregorian Calendar at
      the date associated with the country_code.  If not
      specified, ncal tries to guess the switch date from the
      local environment or falls back to September 2, 1752.
      This was when Great Britain and her colonies switched
      to the Gregorian Calendar.
pasc187821 minutes ago
It depends on the country.

1582 is Catholic Europe

1700 or 1701 is Protestant Europe

1752 is Great Britain and its colonies which include USA

1918 is Russia

1923 Greece

https://en.wikipedia.org/wiki/Adoption_of_the_Gregorian_cale...

russdillabout 2 hours ago
This is clearly the wrong way to think about it. Dates forward and backward from this flag date exist in both calendars and it's straightforward to convert between them.

Such a flag day didn't involve removing days from one calendar or the other, it switched between them.

slazaroabout 2 hours ago
The way I imagine it is like the calendars are both rulers that are slightly off from each other. We were using one ruler, and at a certain point we went from using one to the other, so our "present" was never mapped to those dates. But you can represent any point in time as any of those calendars, like we can represent a specific temperature as Fahrenheit or Celsius. The calendars extend forwards and backwards to infinity.
da_chickenabout 2 hours ago
It's not a wrong way to think about it. There are some use cases for proleptic calendars, but there are just as many where it's completely inappropriate. If you ever need to compare what day you think it is with what day someone in the past thought it was, then yes those dates don't exist in any real sense.

I wouldn't say it's it's straightforward to convert between them, either. The Gregorian calendar was first adopted in 1582, but the UK and it's colonies didn't follow suit until 1752. Russia didn't convert until 1918, and Greece didn't switch until 1923. We're just over 100 years out from active use of the Julian calendar. So you have to know who the speaker is and where they are or where they are from to know what they mean.

Since these places switched at different times, they had to skip a different number of days. It was 10 in the 16th century. It was 13 in the 20th!

If you're reading a journal by a British man who lived in Russia through the end of the Great War and then moved to Greece in 1920, what does he mean when he's talking about a lunar eclipse he just witnessed?

Asraelite22 minutes ago
I would say it's almost never appropriate unless you're directly quoting source texts.

If you are talking about a historical event from Egypt in 500 BCE, you would say "this happened in 500 BCE", not "this happened in year 26 of the 27th dynasty".

The distinction is important in the context of doing historical research, but it is no more appropriate to write dates in secondary sources using the Julian calendar than it would be to try to explain Egyptian history by spouting hieroglyphics at people.

pibakerabout 3 hours ago
The article is a bit old. It should have noted a new development in calendar technology if it was written half a year later.

> In A.D. 1582 Pope Gregory XIII found that the existing Julian calendar insufficiently represented reality, and changed the rules about calculating leap years to account for this. Similarly, in A.D. 2013 Rockchip hardware engineers found that the new Gregorian calendar still contained flaws, and that the month of November should be counted up to 31 days instead.

https://lwn.net/Articles/669022/

maxlybbertabout 2 hours ago
This is an interesting detail to learn about history. However, like the article mentions near the end, the Gregorian calendar was adopted at different times in different countries. The Anglican Church didn’t trust the Catholics, so Great Britain adopted the Gregorian calendar in 1752 ( https://en.wikipedia.org/wiki/Calendar_(New_Style)_Act_1750 ). And they did their best to hide the fact that they were adopting a Catholic invention: it’s the “New Style Calendar” and they came up with a different way to choose the same date for Easter.

1752 is late enough that Benjamin Franklin, George Washington, Thomas Jefferson and others were born before that change.

I think that’s the reason that programming languages tend to adopt the proleptic Gregorian calendar and leave it up to the programmer to figure out when the calendar was adopted in the countries they care about.

Except that countries apparently had to answer various questions when they adopted the Gregorian calendar, and they didn’t all chose the same answers. Ideally, we’d have something like tzdb but for calendar adoption. But I guess the need doesn’t come up all that often.

tshaddoxabout 1 hour ago
The British (including the American colonies) also did an arguably even more confusing calendar change in 1752, by switching the start of the new year from March 25 to January 1.
jaculabilisabout 3 hours ago
> The Eastern Orthodox church even continued well after that, only switching to the Gregorian calendar in 1929.

Technically, they switched to the Revised Julian[0] calendar, not the Gregorian. Also, it was only some of the churches making up Eastern Orthodoxy that switched; others remain on the Julian calendar to this day, and all of them still use the Julian calendar to calculate the date of Pascha.

[0] https://en.wikipedia.org/wiki/Revised_Julian_calendar

_verandaguyabout 3 hours ago
Fun related fact, many dates -- for example, birth dates on headstones -- of people born in countries observing Eastern Orthodox Christianity will have the prefix O.S. (old style) to disambiguate dates using the original Julian and either the Georgian or Revised Julian calendars which were in effect at that person's death.
KWxIUElW8Xt0tD9about 3 hours ago
A primary reason for the Catholic Church changing the calendar was to bring the date of Easter back into conformance with the decree of the Council of Nicaea on the topic. There was a controversy in the early Church on this, there were even miracles worked concerning the correct date -- see Dom Gueranger's "Liturgical Year" for some of the accounts.
throwawayk7habout 1 hour ago
So, the Proleptic Gregorian Calendar[1] refers to what you'd get if you extended the current Gregorian Calendar back in time before its introduction. (It agrees with the Julian calendar only during the 3rd century AD.) Most date libraries use the Proleptic calendar for simplicity. Ruby's DateTime is unusual insofar as, by default, it actually switches to the Julian calendar for dates before Oct 15 1582.

[1] https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar

wduquetteabout 1 hour ago
Using the proleptic Gregorian calendar for historical dates is only a problem if you want to compute the day of the week (which those missing days will throw off prior to the adoption of the Gregorian calendar in the relevant country) or the number of days between two historical dates (if the two dates span the date when the Gregorian calendar was adopted).

And, frankly, there are other problems to deal with beyond correctly handling the Julian/Gregorian switch. In Nelson's Navy, for example, the new day started at noon rather than midnight as we'd expect. AM could be June 1st, PM could be June 2nd, and both could be Tuesday.

And then there are lots of historical events with dates like "on or about August 6th" or "mid-September" or the "in the Fall of".

Trying to deal with historical dates in what a programmer would consider a perfectly correct way is something of a fool's game.

gmuecklabout 2 hours ago
This article presents a grossly simplified version of events. The truth is that only some catholic countries switched in 1582. Britain and its colonies switched in 1752. Prussia switched in 1610. And so on.
1-moreabout 1 hour ago
Hadn't Britain established the C of E permanently by 1570, so it wasn't part of the Catholic world any more?
Advertisement
elendilmabout 2 hours ago
Dates really are a headache.

In our Dip (in house db) client library, we built what we called a policy that auto selects partitions based on every crud operations. The policies can be specified once for each collection in collections.json based on fields or query.

So for policies where partition involves the date type fields, be it range or fixed dates, it was incredibly hard to generate universal date names from ranges.

The policy mechanism was finished fairly quickly as Dip is inherently distributed first. But reasoning about date names was so incredibly hard.

The missing dates mentioned in the article did come up during development adding to the woes.

But the upside now is that application code no longer worries about the distributed partitions. Policy handles that. Some sort of architecture as code. Don't know whether AAC is an existing term or whether we coined it.

laveurabout 3 hours ago
I tried to create a date object in Swift from the date October 5, 1582. The resultant date object was October 15th 1582.
Cthulhu_about 3 hours ago
This is (weirdly) in line with behaviour I've observed in iOS's date picker; if you set a block of dates as not available, and the selected date inside of that unavailable block, it will automatically select the first available date on open.
shagieabout 1 hour ago
... And then there was Sweden.

Instead of flipping the switch in the 1500s... or 1700s... they instead did a slow roll out until they finally flipped the switch and did a big leap.

https://www.americanscientist.org/article/date-distinctions

    In “The Future of Time,” the authors state that “different countries and religions adopted the reforms [the Gregorian calendar] at different times and in different ways. In 1712 Sweden added a February 30 to its national calendar.” There was a February 30 in Sweden in 1712, but the context in which it is presented in the article is misleading. In 1700 the Swedes decided to switch from the Julian to the Gregorian calendar by eliminating leap-year days for 40 years. So 1700, which is a Julian leap year but not a Gregorian leap year, did not have a leap day. In both 1704 and 1708, through bureaucratic error, there were leap days. In 1712, the situation was resolved by switching back to the Julian calendar; this meant that the missing leap day that would have occurred in 1700 had to be added, and was, as February 30. It wasn’t until 1753 that the Swedes finally adopted the Gregorian calendar by making the date March 1 follow February 17.
JoshTriplettabout 2 hours ago
Is the stack trace in the Ruby transcript invisible for anyone else? It seems to show up as white text on a white background.
woodruffwabout 1 hour ago
Yep. This post is really old, I probably broke the CSS for these older posts a long time ago and never noticed it. I can try and fix it later today.
charlieyu1about 2 hours ago
Are we really supposed to trace this given how ancient it is? If we really want to do far we would eventually reach ancient Chinese emperor era names that even confuse historians
1313ed01about 3 hours ago
I wonder how many libraries correctly handles the date 1712-02-30 in the Swedish calendar (according to Wikipedia the only official 30th of February in history)?

https://en.wikipedia.org/wiki/List_of_non-standard_dates#Feb...

Tried using ncal like in the examples in that blog post, but it did not work correctly using either Julian or Gregorian. Of course the Swedish calendar from 1700-1712 was neither, but somewhere in-between, because of the (failed) attempt to gradually move from one to the other.

throw0101dabout 3 hours ago
opelloabout 2 hours ago
But that redirect (intentionally or not) doesn't include the fragment part of the URL, so it might not have satisfied the other poster's intent.
adbachmanabout 3 hours ago
I ran into this in a Ruby on Rails test suite a few years ago and wrote up my findings here: https://gist.github.com/abachman/f97806e1c0fe8e4e1849e5f8412...

tl;dr - ActiveSupport::TimeWithZone used absolute seconds counting to determine dates while DateTime used a proper Gregorian calendar. This means dates before October 15, 1582 have different internal values when compared.

The behavior showed up because a test was using a DateTime value to set a MySQL DATETIME column to the DB minimum value, which is 1000-01-01 00:00:00, and then comparing the DB record attribute to the original variable used to set it.

Something like:

  date = DateTime.new(1000, 1, 1, 0, 0, 0, 'UTC')
  record.update(happened_at: date)
  record.happened_at == date # => false
I "discovered" the missing Gregorian dates when I wrote a loop counting forward in time from Jan 1, 1000 until the corresponding TimeWithZone and DateTime records returned true when compared with ==.
clordabout 3 hours ago
I suppose the Georgian calendar includes this gap officially? Or did the catholic world just jump from system to system? If it includes the gap officially, then yea, error is the right thing. But if we just moved to a new calendar, then arguably there should be no error. both calendars work for all dates continuously, and we could have conversion functions etc. The gap is just a big flag day (week.)

imo, if i am using Georgian i want that system even retroactively, just like projecting a date back into the stone age. I don't care that a particular geography or culture changed calendars.

So I suppose what is really going on is that some libraries are using Georgian consistently, and others are using some hybrid "civic" calendar that tracks what the romans and the catholics were using, so dates in history books make sense.

bombcarabout 3 hours ago
Contracts and other similar types of financial instruments existed by this time there must be some way they handled it because something that said that it happened on a date that never occurred - sounds like what lawyers live for.

I’ll draft a Dubia so that when future popes change the calendar they will include a representative code sample and details about how we handle this.

(It’s important to remember that the pope and friends were operating much more like an international standards body than a religious leader when doing things like this.)

wongarsuabout 3 hours ago
If a contract dated to the 4th October 1582 specifies you have 15 days to make payment, you would indeed need to know where that contract was signed to determine on what day that deadline expired.

And if there is a contract dated to the 6th October 1582, that does raise questions about its legitimacy (though in general misdating a contract does not void it, it would merely be one point of evidence in your argument that it's a forgery, just like using a particular font in a modern printed contract)

bombcarabout 2 hours ago
I was thinking of contracts that say "payment is due on 6 October" from before they knew the date of the change.

It's one of those "well technically" things programmers love to obsess over and the judge just says "everyone knows what was meant, stop being an idiot."

madcaptenorabout 1 hour ago
I assume there is a way to handle this in modern contract law. Surely people have forgotten how long the various months are and written contracts referring to April 31.
1-moreabout 1 hour ago
> there must be some way they handled it because something that said that it happened on a date that never occurred - sounds like what lawyers live for.

Yeah there are a lot of examples of dates being written two ways on the same document/artifact. In the Anglosphere there are two changes that happened close together: the movement of the new year from Lady Day to the first of January, and the Julian/Gregorian calendar jump, so that confounds things slightly. https://en.wikipedia.org/wiki/Old_Style_and_New_Style_dates

poizan42about 3 hours ago
The proper name for the calendar using the Gregorian system before the start of the Gregorian calendar is "the proleptic Gregorian calendar".
flotzamabout 3 hours ago
And indeed that's Python's calendar:

'A date object represents a date (year, month and day) in an idealized calendar, the current Gregorian calendar indefinitely extended in both directions.'

'This matches the definition of the “proleptic Gregorian” calendar in Dershowitz and Reingold’s book Calendrical Calculations.'

https://docs.python.org/3/library/datetime.html#id2 https://docs.python.org/3/library/datetime.html#id5

Whereas Ruby has proleptic Gregorian Time, but civic DateTime:

https://ruby-doc.org/stdlib-2.6.1/libdoc/date/rdoc/DateTime....

matsemannabout 3 hours ago
Think it depends on usage? Taking October 1st and 20th, and you want to know how many days passed, what's the right answer? If it's days lived, you would want the answer to not be 20, as some of those days didn't happen. But in some other context (perhaps something transitioning to the calendar earlier), they did?
reaperducerabout 3 hours ago
Regarding computers and time, I always liked that in AmigaDOS, you could specify custom relative times.

It would natively display "Future" if the file timestamp was ahead of the system clock, but you could also add dates. I remember seeing directory listings like

  xyzzy.foo 49152 ----rw-d Christmas 1988
kfseabout 3 hours ago
Ok now do date math, does the day-of-month accurately jump over the non-existent numbers?
Advertisement