-
-
Notifications
You must be signed in to change notification settings - Fork 31
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] Default to system timezone in toZDT
if none is explicitely set
#307
Conversation
Signed-off-by: Richard Koshak <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Signed-off-by: Richard Koshak <[email protected]>
We have fixed the problem but only for Strings. 😭 I should have thought of this. It does not work when the DateTime Item or the raw DateTimeType is passed to See the following code with the results:
Results:
I was so focused on the toString that I forgot about Items and states too.
|
Yes, we need both RegEx(es) anymore, because IMO it should be possible to parse a ZDT from an (ISO) String containing a timeline or not containing a tz. I am against changing the existing utils function, because IMO the utils should simply convert and not set any defaults. I would add a warning regarding timezones to the utils method’s docs and introduce a private method to time.js to default to the system time zone for all usages of the utils method inside time.js |
Or should we add this as a new utils method? |
That was working before though, wasn't it? The only problem was that those Strings that were parsed without the zone id wouldn't handle
That seems reasonable.
I like the idea of keeping like stuff together. I'm not certain why the utils method is in utils in the first place nor where that util method is used. This feels like a similar function though so it makes sense to me to make a new utils function that time.js calls. I'll fix the regex so the builds become happier. |
Exactly. Those RegExp can be kept as they currently are in this PR.
When helping out @jlaur with JS scripting examples for his energy prices binding, we noticed that there might be the need to have such a method. Of course toZDT is able to handle that as well, but given the number of javaToJS functions we already had in utils, I thought it would be useful to provide a simple conversions for ZDT there as well. If I want to convert a Java type to a JS type, I always look first at utils, as this is the dedicated place for such stuff. I guess the utils methods are mostly used by the library internally, where we often need type conversions. Compared to |
For reference: |
That makes sense. Because this is very much like the existing utils method I think it should probably go there and then have the time method call the new function from utils instead of the old one. It will probably be late today but stay tuned for a new commit. The changes are super easy thankfully. |
@rkoshak Whats the status here? Should I take over? |
Unfortunately I've not been able to get back to this. It's still at the top of my todo list but stuff like mitigating a burst pipe and planned family activities have eaten up most of the time I have to work this. If you have the time I'm happy to let you take over. |
Signed-off-by: Florian Hotze <[email protected]>
Signed-off-by: Florian Hotze <[email protected]>
Signed-off-by: Florian Hotze <[email protected]>
Signed-off-by: Florian Hotze <[email protected]>
Signed-off-by: Florian Hotze <[email protected]>
Signed-off-by: Florian Hotze <[email protected]>
Signed-off-by: Florian Hotze <[email protected]>
toZDT
if none is explicitely set
Fixes #306.
During DST changes, any ISO8601 String or Item or DateTimeType or Java ZonedDateTime
that is parsed by
time.toZDT()
lack the ZoneId.However, it is this ZoneId which tells Joda when DST changes occur so when
toToday()
is called, the time is not adjusted to account for DST.This defaults to the system timezone if no timezone is explicitely set.