7

From what I have researched it is not possible to change the Timezone of a thread. So my question is why can't you?

I would have thought switching your application's culture to a specific country would also switch this, seems like expected behaviour IMO.

Edit

After revising I can see the reason why it probably shouldn't be mapped 1:1 by default. However, I still feel it would be a nice feature to be able to change the Timezone per thread.

James
  • 80,725
  • 18
  • 167
  • 237

2 Answers2

10

They aren't a 1:1 so they're not really connected. If you set the current culture to en-US, which timezone is that? :)

Several countries have more than 1 timezone, so setting the culture (which is not country specific either for that matter), doesn't really have much to do with the timzone.

Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155
  • +1 Good point! Never thought about it that way. Wouldn't it have been a good idea to do this for ones that *don't* have multiple timezones though? – James May 30 '10 at 12:32
  • 1
    @James - Nope :) You should always go for *consistent* behavior in an API rather than "do this in *some* cases *if* you can", that's asking for trouble and helpdesk calls. Predictable > doing as much as possible – Nick Craver May 30 '10 at 12:34
  • I would have been nice if the CurrentCulture had an overload that took in the Timezone id though :) – James May 30 '10 at 12:36
  • @James - Extension method! :) – Nick Craver May 30 '10 at 12:40
4

Culture is one thing, time zone is another. Suppose you're a South African citizen working in New York, USA. Obviously you want your time zone to be EST (GMT -5), since that's where you are; from what you're suggesting, however, then if you also set your culture to "af-ZA," as you might want to, doing so would automatically change your time zone to GMT +2.

Dan Tao
  • 125,917
  • 54
  • 300
  • 447
  • Yeah after revising I realise they probably shouldn't be mapped by default. However, would be nice if you could set the Timezone of the thread also. – James May 30 '10 at 13:11
  • @James: That would indeed be nice. There are certainly other ways of tackling this problem, though. For instance could your application maintain its own offset from UTC -- which could be modified during runtime -- and use this offset in all places where the time is needed? – Dan Tao May 30 '10 at 13:37
  • At the moment I do have a solution and doing the conversions on the fly. Just thought it would be easier if I could change the Timezone per thread and eliminate the conversions completely. – James May 30 '10 at 14:08