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

Handling of days and weeks in CalendarDiffTime #210

Closed
dcastro opened this issue May 27, 2022 · 4 comments
Closed

Handling of days and weeks in CalendarDiffTime #210

dcastro opened this issue May 27, 2022 · 4 comments
Milestone

Comments

@dcastro
Copy link

dcastro commented May 27, 2022

If I understand things right, as of #40, we can parse "P1DT1S" to CalendarDiffTime using durationTimeFormat:

However, CalendarDiffTime normalizes the "days" and "weeks" units (D and W) and assumes all days have a standard 24 hours.

> formatParseM durationTimeFormat "P1DT1S"
P0MT86401S

On the other hand, the parser durationDaysFormat for CalendarDiffDays does correctly handle "days" and "weeks", but it does not handle smaller time units like hours and seconds.

Should there be a type that handles strings like P1DT1S correctly? A type with 3 fields, for months, days, and NominalDiffTime?

@AshleyYakeley
Copy link
Member

Hmm, it would be better if the CalendarDiffTime type were changed...

@AshleyYakeley AshleyYakeley added this to the 1.14 milestone May 27, 2022
@dcastro
Copy link
Author

dcastro commented May 27, 2022

Yes I thought so too, but didn't want to suggest a breaking change ^^
If you're okay with that, I'm all for it!

@AshleyYakeley
Copy link
Member

So this part I definitely want to fix:

> formatParseM durationTimeFormat "P1DT1S"
P0MT86401S

The Show instance should use larger units, and in this case should return "P1DT1S".

On the other hand, I would prefer 12H + 12H = 1D: this is what people expect. I don't think it's worth supporting leap-seconds in this type. So I don't think the type should be changed.

@AshleyYakeley
Copy link
Member

OK, fixed the Read and Show instances to use the ISO8601 code.

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