dateparse icon indicating copy to clipboard operation
dateparse copied to clipboard

Not parsing older years well

Open crwallace opened this issue 6 years ago • 1 comments

It appears that any date with two-digits years in the 1940s and 1950s is getting parsed as 2040s and 2050s.

I am unable to find the code for setYear() to look at the rules because the parsing looks correct beginning in the 1970s.

crwallace avatar Jun 12 '19 14:06 crwallace

I believe this is the behavior of underlying golang parse. One idea would be to cause this to be an error for 2 digit yy type format's, but it is inherently ambiguous and as such, the only real approach i can think of is cause ParseStrict() to throw an error? https://godoc.org/github.com/araddon/dateparse#ParseStrict

https://play.golang.org/p/dp9CQ1fegRn

package main

import (
	"fmt"
	"time"
)

func main() {
	d := "03-03-55"
	tout, _ := time.Parse("01-02-06", d) 
	fmt.Printf("out:  %v\n", tout)
}
>> out:  2055-03-03 00:00:00 +0000 UTC

araddon avatar Jun 15 '19 21:06 araddon