-
Notifications
You must be signed in to change notification settings - Fork 82
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
Best way to get the raw timezone #9
Comments
Hi Rudolph, Thanks for posting this. Right now, you're correct, there's no way to do this. Not that I don't want it to do that, only that I hadn't really considered it. Perhaps a new option could be added, such that the argument Then, that way, we could ensure that any conversion will retain any timezone specific information for users that wish to retain it. You would then be able to call something like:
I'm open to a PR if you're feeling up to it :) |
I've managed to do it. But I am thinking of the bigger problem. Technically speaking, Erlang's date/time is broken because it is: So for the last while I've been working to fix that and wrapping Erlang's calendar, date and time stuff into a new library with new types that are properly tagged. My current implementation uses records, one each for date, time and datetime. And I've ported calendar so that it works with the new types and with existing types. All I had to do was add support for timezones and that was why I started playing with your library. I am very tempted to see if you'd be open to merging the two and then we publish one date/time library that solves the problem. I'm not quite done. But it it works. You can look here to see what I am attempting to do: https://github.com/rvangraan/datetime/tree/timezone-integration The import part is the The records look like this: What do you think? In my code I've called my new
That results in a map of properties like so:
You'll also see that I've been trying to add eunit tests as much as possible in my code. |
Another thought... I am very tempted to get rid of the records altogether and switch to maps. that way, you'd end up with something like this This will have the benefit of solving this problem:
The first is just a date, no time. I am of two minds on whether one should tag the individual date fields with What do you think? |
Very interesting. I'm pretty okay with the idea of using an internal format for A Better Date Object (TM), and records are a solid and safe way to go with this route. I'm definitely open to merging in functionality to make the date components always available in some raw format (like a record containing all the details), while retaining the I have to disagree on the maps, though. I prefer the idea of going with records over maps mainly for backwards compatibility. Beyond the syntax, the only thing maps would do to improve our situation right now would be an easier upgrade process (if users were storing the raw parsed date format instead of something more "portable"). What would be your thoughts on this, merging in your datetime lib, and adding it as one more output function (like, say The work that you've done so far on datetime looks very nice, and feels to me like the next logical step to improving things overall. |
Oh, and as far as storing the date and time as 3-tuples or as individual fields (hour, minute, day, etc), my gut right now is telling me individual fields is better for one reason: support for subsecond accuracy gets hairy because then you're pattern matching against a 3 or 4-tuple with a microsecond accuracy as the 4th element (for iso8601 subsecond stuff, which ec_date supports, but which I've not yet modified qdate to handle), and the code just feels like it'll be nasty dealing with that. |
Any thoughts on this? |
Bumping this, as I'd really like to be able to extract timezone information from a string. |
@choptastic Here is my PR regarding the subject: #28 |
Hi there,
What would be the best approach to add a function that returns the timezone for a given date (string or otherwise)? I need:
Ultimately it is about parsing whatever date and timezone into its components and timezone so that it can be maintained. I don't want the implicit conversion of the timezone when using to_date/1. The plan was to use this bit of code to do that:
Thanks,
Rudolph
The text was updated successfully, but these errors were encountered: