Closed 238855 closed 3 months ago
Yeah, the docs are just wrong here. It should say this:
Set the cutoff year for whether a 2-digit year string is interpreted in the current or previous century. Numbers higher than the cutoff will be considered to mean 19xx and numbers lower or equal to the cutoff will be considered 20xx.
This makes sense and is the right thing to do (e.g. '89 means 1989 but '17 means 2017) but the docs are backward.
I've fixed the doc string and examples in 73c44388 though it won't make it to the site until we do another release.
Thanks for the report!
Describe the bug This seems like a documentation error.
The line of code that is supposed to acheive this is
} else return year > Settings.twoDigitCutoffYear ? 1900 + year : 2000 + year;
(Link)To Reproduce See RunKit links for Actual vs Expected behaviour.
Actual vs Expected behavior
Expected If I set the cuttoff year to
0
then I expect all years in range00 - 99
to be interpreted as2000 - 2099
(current century)Actual If I set the cuttoff year to
0
then I all years in range00 - 99
are interpreted as1900 - 1999
(previous century) https://runkit.com/238855/65defe178dd6300008b6837fWorkaround To have all two-digit years be interpreted as current century, use
Settings.twoDigitCutoffYear = 99
https://runkit.com/238855/65deffb6da3d3000087906dc