question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Serializing `FixedOffsetTimeZone` doesn't produce timezone database entry

See original GitHub issue

When serializing the constant TimeZone.UTC, which is a FixedOffsetTimeZone, I was seeing the value "Z". Comparing this against the tzdb, I don’t believe this to be the right value. I believe the correctly encoded value should be one of:

  • Etc/Zulu
  • Etc/UTC
  • Zulu
  • UTC

Is it possible the Z is the serialized form of the offset portion of an ISO 8601 String? Is that to be expected? I would expect the serialization of a TimeZone to yield the tzdb name.

I am unsure if other instances of FixedOffsetTimeZone experience the same problem. I’m happy to help dig in if more info is needed.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dkhalanskyjbcommented, Dec 16, 2022

Yes, but what end function does this serve?

I see the difference between them as the difference between numbers (5, -10) and functions that return numbers ({ _ -> 5 }, { _ -> 10 }). Another analogy is the difference between a clock reading (the position of the hour and minute hands) and a clock that is stuck. Is a clock that is stuck forever literally just the time that it shows?

A time zone is a function that maps the actual time to the UtcOffset that is used in that location at that moment, and a fixed-offset time zone is, when seen like this, a constant function.

What end functions (that I’m potentially unaware of) does a FixedOffsetTimeZone facilitate that a UtcOffset cannot?

FixedOffsetTimeZone, as you saw, also stores the name of the timezone. For example, GMT and UTC are both timezones that are fixed-offset and always have the UtcOffset value of zero, but they even have different Wikipedia pages: https://en.wikipedia.org/wiki/Universal_Time https://en.wikipedia.org/wiki/Greenwich_Mean_Time Time zones are used not only for computation but also for communication. If someone says something is in the GMT timezone, maybe the do want to highlight that it’s not the UTC timezone. Who knows.

1reaction
ilya-gcommented, Aug 22, 2022

java.time has the class ZoneOffset which is an inheritor of ZoneId and combines the functionality of expressing an offset from UTC and using it as a time zone. We decided to split these aspects into separate classes. It’s true that FixedOffsetTimeZone and UtcOffset have the same representation when serialized to string, but it doesn’t mean that their functionality is duplicated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Time zone database file format - Noda Time
Time zone database file format. This document describes the Noda Time-specific binary file format that is produced by Noda Time's NodaTime.
Read more >
How to add timezone offset to JSON.NET serialization?
Strange thing is if I create brand new DateTime object and assign to DateTime.Now without binding, JSON.NET will append timezone offset to it....
Read more >
Serialization/deserialization does not round trip #45 - GitHub
I'd be happy to take a PR that changes the serialization of timezones to the full name. Tz deserialization may still fail if...
Read more >
timezone - Amazon Redshift - AWS Documentation
Because time zone abbreviations, such as PST or PDT, are defined as a fixed offset from UTC and don't include daylight savings time...
Read more >
Time Zone Database Parser - Howard Hinnant
The effect of this pairing is to create a time_point with the exact same UTC time point, but associated with a different time_zone...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found