inukshuk / edtf.js

Extended Date Time Format (ISO 8601-2 / EDTF) Parser for JavaScript
BSD 2-Clause "Simplified" License
66 stars 12 forks source link

Add support for century zero #3

Closed darthsteven closed 8 years ago

darthsteven commented 8 years ago

Right, let me be clear, I think that this is a hack, and probably shouldn't be merged.

This is an attempt to help out with #2.

I have noticed that the concept of Century in this library doesn't match with the 'English' concept of Century.

For example, I would say to someone: "This happened in the 20th Century" and I would mean that it happened at some point in the year range: 1900-1999

However, the edtf.js library Century 20, i.e. edtf.Century(20) covers the period: 2000-2099. But, creating Century(0) isn't allowed by the library.

I'm looking to 'solve' the issue where I need to find the min/max of dates like 01XX and 00XX. Note that as per #2 this currently doesn't work, but if I just remove the 'XX' on the end of the years, it does.

01XX is converted to 01 and then min/max work correctly.

However, 00XX is converted to 00 which is then invalid :(

So, this PR allows creating Century(0) and also cleans up the handling of negative centuries, as the year/min/max was wrong there.

inukshuk commented 8 years ago

Thanks for this, I'll try to address #2 in the next few days and also assess this PR.

I think you're conclusion is absolutely right, we'll need a century 0 -- the ISO spec is very strict regarding the semantics of the century syntax (and yes, it's not intuitive in many languages), so it seems a '00' is required.

inukshuk commented 8 years ago

Both ISO 8601 and EDTF support a year zero anyway (astronomical calendar) so this is very straight forward. Thanks!

darthsteven commented 8 years ago

Yey! Thank you.