TimeSpanParser
TimeSpanParser copied to clipboard
Issue with years parsing
Years parsing seems a bit weird: while this works TimeSpanParser.Parse("0 years"), neither TimeSpanParser.Parse("1 years") nor TimeSpanParser.Parse("1 year") work.
Any ideas why this happens?
EDIT: Just noticed this in the readme: ". . . Other values for years/months are not currently accepted". Would be nice to have 1 year just equal 365 days or something in scenarios where leap year is not that important.
Hi, yes I left it out deliberately because of the ambiguity, implication of relative timespans, and added work to support all possible "correct" values of "1 year" or "1 month". I also didn't have a use case. Can you tell me about yours?
I was building an internal command line tool for generating licenses. The expiration parameter is parsed using this library. Licenses usually last for years, but when I entered "1 year" it failed to parse, which was unexpected initially. Setting 365 days is a good enough workaround for now though.