-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Missing conversions in calendar
#8160
Comments
👍 the other day we were also looking at this. Lemme add we feel the following is also missing: conversion from Gregorian seconds to Unix time and back. There's this magic number, |
LOL, so datetime->unixtime is significantly less generic than the other way around and only way to do this is to either datetime -> string -> unixtime or to reimplement logic from the conversion? The conversion is already implemented in EDIT: |
@MarkoMin i also want to point out magic OR mistake here:
|
After the first release candidate, we generally focus on bug fixes and polishing of features already included or planned for the release. To ensure that Erlang/OTP 27 will be as good as it possibly can be, we need to minimize the time we spend on things not to be included in the release. Therefore, we will not investigate/consider this feature request until after OTP 27 has been released. If we have not came back to it before September, feel free to remind us. |
@bjorng ping |
Thanks for reminding me. I can't promise that we will implement this, but I'll make sure that it will brought in our next planning meeting. |
After discussing this with the OTP team, it seems that your suggested functions are suitable for for inclusion in |
Is your feature request related to a problem? Please describe.
The problem arises when you want to convert system time to datetime and vice versa. There are functions
calendar:system_time_to_local_time/1
andcalendar:system_time_to_local_time/1
, but the inverse functions are missing (universal_time_to_system_time/1
andlocal_time_to_system_time/1
).Describe the solution you'd like
I'd like those 2 functions introduced. Also,
rfc3339_to_datetime/local_time/universal_time
might be convenient, because currently you have to first transform it to system time and then to datetime/local/utc.Describe alternatives you've considered
Currently, I manually construct RFC3339 string from datetime and then call
calendar:rfc3339_to_system_time/1
, which is both hacky and inefficient.Additional context
These could be nicely property-tested:
T = universal_time_to_system_time(system_time_to_universal_time(T))
.I'm willing to make a PR if anyone can confirm that those functions are suitable to be in
calendar
.The text was updated successfully, but these errors were encountered: