Timezone abbreviation

I have an app that retrieves data from the web that includes datetime in ISO8601 format. Parsing it is not a problem. What I’m wondering about is handling the timezone translation.

The date string has an GMToffset of -07:00 when I feed it to the DateTime object calculated as gmtOffsetInSeconds.
If I then access the DateTime.TimeZone.Abbreviation I get “GMT-07:00” which is correct.

Is there a way to be able to translate the abbreviation as, in this case, “America/Chicago”? Since I can create a TimeZone object using the string I would expect to be able to retrieve it also.

If DateTime.TimeZone.Abbreviation is giving you “GMT-07:00” instead of “America/Chicago” that seems like a bug. The docs say it should give you “America/Chicago” and that’s also the way it works with Xojo.Core.Date.

Hi Dale, the problem I see is that GMT -07:00 could have a different timezone when a name is used, also GMT -7:00 indicates that the time will not have Daylight Saving changes.

America/Chicago is GMT -05:00 while in CDT and GMT -06:00 while in CST.
America/Mexico_City has the same as America/Chicago but they Daylight Saving time changes at different dates (the Sunday that Central Time changed prior to 2007, April-October instead of March-November)

No, it is not a bug. Dale created a date with Timezone(gmtOffsetInSeconds)

There’s no way we could guess correctly every time as there are several “right” answers in each time zone. That said, if you create with “America/Chicago” it should return “America/Chicago”.

That’s the conclusion I came to, also, but I wanted to ask to see if I was missing something.

Actually, it isn’t. Creating a timezone using SecondsFrom1970 doesn’t actually return the timezone name in any version I tried.

In 2019r1.1, using the following code

Dim d As Double = -7 * 3600 Dim tz1 As New Xojo.Core.TimeZone (d) Dim tz2 As New TimeZone (d)
tz1.Abbreviation returns “Etc/Unknown”

In 2019r2, using the following code

Dim d As Double = -7 * 3600 Dim tz1 As New Xojo.Core.TimeZone (d) Dim tz2 As New TimeZone (d)
tz1.Abbreviation returns “GMT-0700”
tz2.Abbreviation returns “GMT-0700”

Overall, I think the returned values in 2019r2 is better since it is valid data rather than a shrug and an “I don’t know”.

Yeah, I missed the part where you were creating the date using a GMT offset, so you should just disregard my comment.