2

I have a web service (MVC Web API) where I store the date time values in UTC. The iPad communicates with the API and will pass the time zone setting in the header. The API will convert the UTC value to the correct local time based on the time zone sent by the iPad.

It seems like I will need a mapping between the list of Objective C time zone values to the C#(.net) time zone values. Other than making the iPad covert to local time, is this the best way?

GMT timezone conversion in objective c

http://msdn.microsoft.com/en-us/library/ms912391%28v=winembedded.11%29.aspx

Community
  • 1
  • 1
HackITMngr
  • 263
  • 3
  • 11

2 Answers2

2

Converting timezone identifiers seems fragile. You could instead send the offset in minutes (like +600 or similar).

On the other hand the cleanest solution seems to let the device make the conversion. Is there any reason you can't do this?

Nikolai Ruhe
  • 81,520
  • 17
  • 180
  • 200
  • I read somewhere that offsets will have some edge cases because of daylight savings but nothing significant. There really wasn't a good reason for not performing the conversion on the device so we went down that road. – HackITMngr Jan 19 '14 at 23:59
  • @HackITMngr The edge cases are when you go the other way around. UTC to local time is deterministic, but some local time values can be 2 different UTC values - when the clock moves backwards due to daylight savings, the same local time happens twice within an hour. This is even more confusing because the term "Timezone" can either to refer to a static offset (daylight savings is ignored), or to the way time flows in a specific place (daylight savings may apply). – Peter Feb 22 '14 at 13:27
2

If by "Objective C time zone values" you mean IANA time zones, such as "America/New_York", then you should use Noda Time in your .NET code.

Preferably, you should just use the IANA time zones as they are. Noda Time fully supports the IANA zones.

However, if you have code where you must use the Windows time zone identifiers, then Noda Time can be used to do the translation. The only reason to do this though, is if you have existing code that uses the .net TimeZoneInfo class.

Additional reading:

Community
  • 1
  • 1
Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
  • We convinced the iPad developers to convert to local time on rather than have the service do it. The Noda time suggestion would have probably worked although I didn't try it. – HackITMngr Jan 19 '14 at 23:54