-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Consider treating weeks as uniform sometimes in the Span
API
#136
Comments
Yeah I've thought about this. The restriction comes from Temporal, which I think has a slightly different concern in play: they support more than Gregorian calendars. And so, I think, weeks aren't necessarily guaranteed to be uniform in that context. (Although I believe they are in practice for the calendars Temporal currently supports.) But Jiff is Gregorian-only and probably will remain so, with crates like So with that said, it does seem like we could make weeks be treated as uniform. However, in #48, it's been brought up that treating days as uniform by default can be somewhat of a footgun in certain circumstances. To fix that, I'm likely going to make days non-uniform by default in all Do you have a specific case you're running into where weeks not being uniform is giving you trouble? |
Thanks for the explanation! The use case I have is for Hipcheck, where we have a small DSL we call "policy expressions" to which we are adding support for basic date and time operations, backed by |
Ah yeah I see. Yeah I agree the pre-processing is the way to go for now. Popping up a level, is there a way to get a meaningful relative date in the context of your DSL? It could be |
We're definitely considering some ways to enrich |
As I understand it from the docs, days are treated as uniform unless a zone-aware datetime is attached, but weeks are (for simplicity) always treated as non-uniform.
This has some implications for things like the
Span::compare
function, where a non-zero week value means theSpan
can't be compared without providing an attached zone-aware datetime.However, in theory the same optionally-uniform behavior that exists for days could exist for weeks, where weeks are treated as being equivalent to 7 days (168 hours), and thus uniform, unless a zone-aware datetime is attached, in which case they are treated as non-uniform.
The text was updated successfully, but these errors were encountered: