dateparse
dateparse copied to clipboard
Cant parse a simple date
] $ dateparse --timezone="America/Denver" "Dec 4 10:19" fatal: parsing time "Dec 4 10:19" as "Jan 2 10:19": cannot parse ":19" as "0:"
Thanks, but I'll look for another utility to do this.
Did you find another option?
thank you for report. Im not sure I am ready to write a fix to that, it entails assuming the missing year is the current year. That sounds like an innocuous assumption but one I feel is just too large of an assumption? If the format you have is stable, then i would use the time.Parse() with your own layout. This lib attempts to allow for different semi-standardish layouts, but without making too many assumptions. open for other comments.
I think there are sufficient use cases where you want to parse dates relative to each other in the context of the date information that is provided. In that, if there is no year provided, being able to parse it successfully with any assumed year is useful so that those dates can still be used. Time.Parse() does this as well by assuming a zero year for information that lacks that information.
Might be worth offering a flag that will assume some information if not present.
I just stumbled upon this failure: 1 April 2022 23:59
is not recognizable, while 1 Apr 2022 23:59
is fine. I think recognition of so many templates is a hell of a task, no wonder we see strange things like that.