How to get timezone from properties in CultureInfo
Asked Answered
B

1

11

I have a string, which contains a timestamp (yyyy-mm-dd hh:mm:ss). I can create a CultureInfo object based on other information I get. Therefore I know which country the timestamp is in. The timestamp is not in UTC/GMT.

Say the timestamp is from Indonesia (new CultureInfo("id-ID")) , meaning the string was created by code below or similar.

DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");

That means the string contains the local time in Indonesia. I know my timezone, but I don't know how to convert the Indonesian time to UTC/GMT, so I can use the UTC/GMT object in TimeZoneInfo. My own timezone may or may not be in the same timezone.

Is there anywhere, this information is connected?

CultureInfo has a lot of properties, surely some of them can be used to get timezone, somwhere?

I might add that I find the entire system very confusing, so I could be way off in how I think things works.

Bird answered 9/8, 2009 at 21:14 Comment(0)
E
10

Short answer: No

Long Answer: This is a 1 to many relationship between culture and timezone. For example: en-US - English, American contains 6 timezones... so how would you get from en-US to Eastern Daylight time? ... and how do you get the daylight savings time offsets?

It's a confusing cultural conundrum (wow, try saying that 5 times fast) that is not easily solvable with the CLR.

Erogenous answered 9/8, 2009 at 21:21 Comment(1)
No I noticed pretty much immediately that this would be a challenge. I've googled about abit, and I found this wiki Time zones by country. There are not that many countries with that many timezones. Australia, Brazil, Canada, France, Indonesia (heh), Mexico, New Zealand, Russia (!), UK, USA +- Now using that as a datasource, and defaulting to the capital city's timezone for the countries with lots of tz, It goes along way. Just airing my idea here.Bird

© 2022 - 2024 — McMap. All rights reserved.