由于silverlight没有完整的TimeZoneInfo,我需要自己实现一些功能。例如,以下信息来自.NET TimeZoneInfo
ID: Central Standard Time
Display Name: (UTC-06:00) Central Time (US & Canada)
Standard Name: Central Standard Time
Daylight Name: Central Daylight Time ***Has Daylight Saving Time***
Offset from UTC: -6 hours, 0 minutes
Number of adjustment rules: 2
Adjustment Rules:
From 1/1/0001 12:00:00 AM to 12/31/2006 12:00:00 AM
Delta: 01:00:00
Begins at 2:00 AM on Sunday of week 1 of April
Ends at 2:00 AM on Sunday of week 5 of October
From 1/1/2007 12:00:00 AM to 12/31/9999 12:00:00 AM
Delta: 01:00:00
Begins at 2:00 AM on Sunday of week 2 of March
Ends at 2:00 AM on Sunday of week 1 of November
我的问题是当我需要从UTC转换为本地和返回时,如何实现此规则?
我应该服用UTC,减去6个小时,然后检查是否是在3月2日星期日凌晨2点之后再添加1小时?
或者我应该接受UTC,检查它是否在凌晨2点之后再减去5?
答案 0 :(得分:1)
夏令时生效的时间是该时区的本地时间,而不是UTC。所以你应该花费UTC时间,减去6个小时,做检查,然后再加上小时(如果适用)。