Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with years parsing #7

Open
lawrence-laz opened this issue Nov 6, 2023 · 2 comments
Open

Issue with years parsing #7

lawrence-laz opened this issue Nov 6, 2023 · 2 comments

Comments

@lawrence-laz
Copy link

lawrence-laz commented Nov 6, 2023

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.

@pengowray
Copy link
Owner

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?

@lawrence-laz
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants