-
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
Add timezone to LocationResource #164
Comments
Would we use the TZ Database Name field (from the Wikipedia list), or the UTC offset (+hh:mm or -hh:mm) which is called the TZD or Time Zone Designator in ISO 8601? |
UTC offset does not reflect whether DST is used, or does it? If not, calculations using the Time Zone Designator will be wrong for approximately half of the year :) |
Well, it is correct in the sense that it points to a single point in time (since it is an offset wrt UTC). It does not tell you how to render it in a specific timezone (which may be using DST and thus vary its offset). The timezone "Europe/Amsterdam" has two offsets defined: a UTC offset and a UTC DST offset. So, if you specify a time, you need to specify the offset (preferably Z, or at least GMT+1 or GMT+2) to point to a specific point on the timeline, and a timezone (e.g. "Europe/Amsterdam") to show how to render it locally (or how it was queried locally). So theoretically, if you have a local time (without an offset) and a timezone, you could determine its offset assuming that DST was used. But that will be very confusing and prone to error. So, please lets use an offset for pointing to a point in time, and specify a timezone as additional information (e.g. how that specific farm likes to see a specific time). |
IMHO there is no real use case that makes use of the offset. Either you have a global system in which you store only UTC date/times or you want to show it to the user. In the latter case, you probably always want to show the "real time as it was on the farm". Otherwise, the "4 o'clock milking" during DST becomes the "3 o'clock milking", which is confusing for the user. I'd expect that every system would be capable of storing a local date/time (no matter whether DST or not) into UTC time. So the only issue would be the way back (i.e. I receive something via ICAR and need to do some conversion e.g. to present the data to the user). Luckily, we just switched back from DST last weekend, so I created a small Java example. So, in Java I can do this:
The output is this:
So, if I have the zone ID, I can just take the UTC time and let Java do the conversion back to the actual user time in CET or CEST respectively. I think, this is what a user would expect. Calculating a time with an offset, I will provide misleading information to a customer. Nevertheless, providing both a zone ID AND an (optional?) offset would be OK for me, but I think at least I will never use the offset at all... |
Hi Thomas, not sure what you mean by 'you will not use the offset', since in your example you use the 'Z' (zulu/zero) offset. Or have you mixed zone and offset? In that case I agree ;) Also, you are only converting in your example between timestamps that contain full information. A better example would be to start from a String in a proposed format. So, with offsets it would be something like this:
And the output is:
However, if we don't specify an offset, there's ambiguity with DST between 02:00 and 03:00, and by default it assumes summertime:
Output:
To show that without an offset it is ambiguous:
Both render the same LocalTime:
|
Hi Arjan, I think we are looking at the same topic from different angles :) The input CET/CEST times were only meant as "starting times" or "times expected by a user" in my example to have different UTC times that I can convert back to something the user wants to see. I'll try to describe more clearly what I mean: Assumptions:
Coming from these assumptions, the question of this issue is: What data do I need in the location resource to be able to convert the UTC times that I receive through the ICAR interface back to local times. Hence, we don't need to look at local times as starting points at all, but only at UTC times. Now that I have a UTC timestamp available, I still have the three options as per point 2 above: use zone id or offset or both:
For me, 2 is useless, as this tells nothing about the time the user had on his watch at the time at which an event happened. Would I rather store the "normal" or the "DST" offset? If both, then this is equal to the zone ID and we could just use that. However, since 3 contains also the zone ID, I could personally accept 3 (including the offset), but I'd never use the offset as I have the zone ID available, which is actually what I want. And for the offset I'd need to figure out whether it is DST or not and whether the location considers DST at all. I think we do not have to think about how a local time (with or without zone id and/or offset) has to be converted to UTC and also the location resource is not related to that issue. It's a problem of the system providing ICAR events that should (or better have to?) reference UTC (= Zulu) timestamps. |
Maybe it comes down to the point: do we want to have non-UTC times in the ICAR interface? |
Haha sorry yes I think we are on the same page:
|
Great! Now we just need to convince the rest of the world :) |
This little part of the world is convinced :-) |
locations end point - add the time zone id = text version "Europe/Brussels" --> ISO standard 8601 --> @thomasd-gea will do |
FYI, the mentioned ISO standard does not reference zone IDs. However, most of the programming languages reference the IANA time zone database, so I referenced that one (https://www.iana.org/time-zones). A nice overview of the codes by global area can be found here: https://www.php.net/manual/en/timezones.php |
I've added a few notes on this on our Design Principles page. |
With #175 merged, I think this ticket can be closed? |
LocationResource should contain a timezone like "Europe/Berlin" (e.g. as defined here https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) to allow converting UTC dateTimes to local ones.
The text was updated successfully, but these errors were encountered: