Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

February 29th on unspecified year #20

Open
SylvainBigonneau opened this issue Nov 13, 2019 · 2 comments
Open

February 29th on unspecified year #20

SylvainBigonneau opened this issue Nov 13, 2019 · 2 comments

Comments

@SylvainBigonneau
Copy link

SylvainBigonneau commented Nov 13, 2019

Using v2.7.1, here is another tricky corner case:

> edtf('21XX-02-29').edtf // expecting '21XX-02-29'
'21XX-03-01'

Since some unspecified year components can match leap years, the library should not move that date to March.

But then we should be careful! Because some other unspecified years such as "21X3" never match a leap year and should therefore behave accordingly.

But right now, the behavior is basically depending on whether the "chosen builtin date" is a leap year, which gives inconsistent results:

> edtf('24XX-02-29').edtf // expecting '24XX-02-29'... good
'24XX-02-29'
> edtf('21XX-02-29').edtf // expecting '21XX-02-29'... wrong
'21XX-03-01'

Would it be possible to check whether there is a matching leap year among the ones matching the year component, and set the Date element to the first occuring leap year?

@inukshuk
Copy link
Owner

inukshuk commented Nov 13, 2019

Ha, yes, that's a good one!

We should think about this carefully, as you say, because this could easily get out of hand. Since the only thing we should be looking to achieve here is consistency, I think we might be able to do something along the lines of:

  1. Do nothing unless the input is 02-29 (I think if it's any other day, we're fine, regardless of which year we default to)
  2. If the input is Feb 29, then set the year to the first leap year that also matches the range.
  3. If there is no such year then I think the current behavior is correct.

@SylvainBigonneau
Copy link
Author

Looks great.

We can also wonder about the desired result of edtf("201X-02-28").next() and edtf("201X-03-01").prev() in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants