-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Proposal: Support parsing month #1
Comments
A month is not a fixed time like weeks, days and patterns below them. A solution is suppose that a month is a fixed 30 days, but this doesn't seem right. |
I have the same issue for months and years ^^ |
I will open the issue for proposals. How many days in a month can be set before the parse because month is not fixed, same with year that can be leap. |
And how to convert 1+ months? This package is for duration, so If user want a duration of three months, the expect, for example, from January 1 to April 1, using 30 or 31 fixed days cannot solve this. |
@xhit What about Rust's approach? https://docs.rs/parse_duration/latest/parse_duration/ "Years are defined using the average over 400 years in the Gregorian calendar. As such, a year is equivalent to 365.2425 days. A month is defined as one twelfth of a year." |
And for those wondering what's the basis of 400 years, it is a full gregorian calendar cycle. "Calendar cycles repeat completely every 400 years, which equals 146,097 days.[1][2] Of these 400 years, 303 are regular years of 365 days and 97 are leap years of 366 days. A mean calendar year is 365+97/400 days = 365.2425 days, or 365 days, 5 hours, 49 minutes and 12 seconds.[3]" |
Hi, sorry for delay and sorry for grammar mistakes, I'm learning English. @gabrielmocan the actual calendar cycle has a desfase, we need to add a day every 3300 years. With duration we need to be precise and simple, so the Gregorian calendar can be used, but isn't perfect enough. Using continued fraction we can get that a more precise and simple, so a mathematical calendar is 365+1211/5000. This has 1 day of desfase every 800,000 years, only we need to change the rule a little:
But the real problem here is: what to expect if the duration is @baoyachi I can see that one month is fixed 30 days, and 1 year is fixed 365. Am I correct? If yes, I think it's fine to leave that to the devs, if they aren't ok with that they can add or subtract to the duration and make the package simple. |
this approach @gabrielmocan mentioned (year = 365.25 days, month = 30.44 days) is also used by "systemd", see https://man7.org/linux/man-pages/man7/systemd.time.7.html so IMO this would be a generally accepted solution, at least as a default
my answer: this depends on the given offset and should be handled by the Add method. |
When I have a duration "1M", I need to parse it as "1 month". I hope to add this feature.
The text was updated successfully, but these errors were encountered: