2

I need to save timezones - along with other data - to a file and read the file from multiple platforms (Linux, WinRT, Windows Phone 8, OS X, Android, iOS). Likely languages are C++, C#, Java, and Objective-C.

Saving the timezone offset as a double is insufficient for my needs, because this loses daylight savings information, which is important. Depending on the date and the timezone, 2 am + 2 hours could be 3 am, 4 am, or 5 am.

Is there a universally supported serializable timezone format?

Peter
  • 5,608
  • 1
  • 24
  • 43
  • I am not sure if you need something different than ISO 8601. Do you need to store the time, or are you only concerned about timezone offset ? – kokeksibir Feb 22 '14 at 11:28
  • Neither. Timezones have a dynamic offset, which in the case of daylight savings changes twice a year. That's why - if feasible - I want to save the timezone, not just the static timezone offset. A single-platform approach for this is to use the `TimeZoneInfo` class in .NET. – Peter Feb 22 '14 at 11:38
  • To the best of my knowledge, timezones do not have dynamic offset. But country/region switches between timezones for daylight saving. For instance, my country uses EET (UTC+2) for winter, and EEST (UTC+3) for summer. – kokeksibir Feb 22 '14 at 11:51
  • I'm referring to Timezone as a concept as implemented here: http://userguide.icu-project.org/datetime/timezone and here http://msdn.microsoft.com/en-us/library/system.timezoneinfo(v=vs.110).aspx – Peter Feb 22 '14 at 12:49

1 Answers1

2

It seems the best answer is to use IANA/Olson/TZDB time zones (which are supported on the Unix based systems), and convert them for the Windows-based platforms. 2-way conversion seems to be unreliable, so the most feasible option seems to be to replace the default datetime framework in .NET with NodaTime, as described in multiple related questions:

Community
  • 1
  • 1
Peter
  • 5,608
  • 1
  • 24
  • 43
  • 1
    Yes. You are correct. See also: [Proper way to store a timezone in a database?](http://stackoverflow.com/q/15824482/634824), which is coming from a different perspective, but is similar in nature. – Matt Johnson-Pint Feb 23 '14 at 22:05