-
Notifications
You must be signed in to change notification settings - Fork 500
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
add datetime functions #1182
Comments
maybe related: #1020 |
Thanks for the detailed writeup! This sounds good to me. I'd be inclined to leave out |
If we're going to go to the trouble of providing functions to operate on datetimes, shouldn't we also make it possible to specify a datetime other than now? If these functions took an epoch timestamp, |
We certainly could let them take a timestamp, although I'd wait to do that until someone has a specific use-case. That way we can ensure that it's both needed, and that what we implement works for the specific use-case. So far I've avoided defining functions that take and return values that aren't strings, e.g., numbers. |
I'd just like to point out that colons in file/directory names can be very problematic, especially when considering multi-platform usage. You can quote or escape them much of the time for creation but many applications and some operating systems will barf hard attempting to manage a file or directory with a colon in its name. Also the colon in the timezone offset is not recommended as well. Some ISO-8601 parsers don't like it for some reason. YMMV. |
I added |
myproject_20220505.bundle
myproject_yyyymmdd_hhmmss.bundle
cmake --build mybuilddir -DBUILDDATE="2022-05-05" -DBUILDTIME="hh:mm:ss" ..
I propose the following functions:
datetime(formatstring)
- Returns the current local time formatted according to the given formatstring. Called w/o parameter delivers theISO8601/RFC3339
representation:2009-06-30T18:30:00+02:00
datetime_utc(formatstring)
- Returns the current utc time formatted according to the given formatstring. Called w/o parameter delivers the ISO8601 representation:2007-12-24T18:21Z
timediff(timestamp1, timestamp2)
and antimesince(timestamp)
function, which can parse two timestamps and calclate the difference. Or with only one parameter calculate the difference between the timestamp and now. The timestamps should be in theISO8601/RFC3339
format. This could be handy to measure execution time, albeit not very performant nor precise.References:
The text was updated successfully, but these errors were encountered: