Closed onecreative closed 10 years ago
That can't be fixed really, someone could make the case the exact other way around as well. I'd add a check after the call if the year is in the future. If it is, subtract 100 years. Would that work for you?
I would default to the most likely. I assume it's in the past for two reasons:
It's the default behavior of moment.js
moment('7/12/68', 'D/M/YY').year()
// 2068
moment('7/12/69', 'D/M/YY').year()
// 1969
I'm sure they had good reasons to put it this way. Finding the right defaults is pretty hard, so I rather stick with the ones from moment, lots more smarter people than I work on it ;)
For what it's worth, here's my after-call check that subtracts 100 years:
if (value.isAfter(moment()) && ref.match(/(?:\/|-)([0-9]{2})$/)) value = value.subtract('year',100);
moment.parseFormat('7/12/65')
parsed the year to2065
, I expected:1965