I get timezone information from another machine in the format :
"CET-1CEST,M3.5.0/2,M10.5.0/3"
(Posix style timezones)
I need to parse this and convert this into a c# .net TimeZoneInfo class
.
Is there a way to achieve this ?
I get timezone information from another machine in the format :
"CET-1CEST,M3.5.0/2,M10.5.0/3"
(Posix style timezones)
I need to parse this and convert this into a c# .net TimeZoneInfo class
.
Is there a way to achieve this ?
I would parse it according to its format: http://www.ibm.com/developerworks/aix/library/au-aix-posix/
Maybe you could also consider: http://nodatime.org/ - I currently don't know if they support this.
According to this article: http://www.ibm.com/developerworks/aix/library/au-aix-posix/ a POSIX time like "CST6CDT,M3.2.0/2:00:00,M11.1.0/2:00:00" has the following specifications:
and the date is in the Mm.n.d format, where:
Well, based on these information and the adjustment rules that could be found in TimeZoneInfo class, you can use this code to do the conversion:
The following code should do the trick.
Do keep in mind that while this will give you a valid
TimeZoneInfo
object, it does not map the information to the existing Windows time zones. You can use the various conversion functions such asTimeZoneInfo.ConvertTime
, but don't expect it to magically know thatPST8PDT
should align to"Pacific Standard Time"
.