1

I'm currently working on a web service using .NET that returns information about the users in a system. This web service has to be general enough to be used by other systems written in Java, PHP etc. My problem is that it has to return the default time zone and I'm not sure about what format I should use to return the time zone, so that it can be easily used by other systems.

What do you recommend?

Nocklas
  • 1,367
  • 4
  • 15
  • 27

2 Answers2

1

The most adopted way of describing time zones is the "Olson" zone info database: http://www.iana.org/time-zones.

Most programming languages and frameworks have libraries to do datetime calculations based on that zoneinfo database. In some cases it is even built in (PHP that I know of), in Python the default implementaion is called pytz. If your are looking for JavaScript implementations there is a time zone detection script here and a datetime calculation script here.

Only if you are working with very obscure frameworks/languages will you need to implement datetime logic around the zoneinfo database yourself.

Since you are working with .NET you may find this question helpful: .NET TimeZoneInfo from Olson time zone. Consider using a library like noda-time which foregoes .NET's TimeZoneInfo in favour of Olson timezones.

More .NET info her: TimeZoneInfo vs. Olson database

Community
  • 1
  • 1
Jon Nylander
  • 8,743
  • 5
  • 34
  • 45
0

I would recommend using the UTC time zone for dates/times. Most languages/libraries have a method for converting UTC to any time zone desired.

If you need to represent the actual default time zone for the user then use the offset from UTC (ex: Eastern Time is -5).

Kevin Junghans
  • 17,475
  • 4
  • 45
  • 62
  • My problem is not choosing a time zone for the dates that my service sends out. The problem is that the users have a default time zone that they want the other systems to show their dates in. – Nocklas Apr 17 '12 at 12:29
  • An UTC offset won't be enough since there are several time zones that have the same offset, but use different DST rules. I have of course thought of sending a full description of the time zone with rules for DST and such, but it would have been nice if there was a better way. – Nocklas Apr 17 '12 at 14:30