-
Notifications
You must be signed in to change notification settings - Fork 10
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
time-period-normalize #19
Comments
There is no such function currently. It could be done for time periods (though note that it could not be done for date periods). Of course, it can only be done for time periods, because gregor doesn't acknowledge the existence of leap seconds. Can I ask what your specific use case is? Maybe there's another way of achieving the same goal? |
Sure. I parse an org file to get time stamps created with |
Once I use period-between, I'm thinking about an absolute time period, rather than a calendar start and end point. Sorry if I'm rehashing your whole design experience here in the issues. |
You could do this by using a combination of time arithmetic and (define p (minutes 61))
(let ([t (now)])
(period-between t (+period t p) '(hours minutes))) (Note that I think this is a reasonable definition of (define (time-period-normalize tp [units time-units])
(define epoch (datetime 1970))
(period-between epoch (+period epoch tp) units)) Without a contract, you could use this on arbitrary periods, but, as I pointed out in my previous note, that would be a bad idea, since the behavior would depend on the function's choice of |
@acarrico Did my previous post help? Do you want to keep this issue open? |
Before I opened the issue I did a version that rolled seconds and minutes up to hours. I stuck with that. It doesn't really make sense to gauge it against a point in real time in this context: the periods are produced from two real time points and therefore already account leaps/daylight savings/etc. in the difference. Really this is just a suggestion that those semantics would be generally useful, so it might make a good utility. |
@acarrico Yes, I think this could be useful as well. I'm going to reopen this. |
I didn't notice a function to normalize time periods, so given 61 minutes, you'd get 1 hour, 1 minute, but given 48 hours, you'd still get back 48 hours. Is this a missing feature, or is there a semantic issue (or am I blind)?
The text was updated successfully, but these errors were encountered: