我目前有一个存储为时区 UTC 日期时间的 DateTimes 列表。当我从 UTC 转换为本地日期时间并且日期落在夏令时标准时间的开始时,重复的时间是凌晨 1 点而不是凌晨 2 点。
我使用以下内容从 UTC 转换为本地时间。请注意,1am 在 local1 和 local2 中重复。我预计凌晨 2 点会重复。
哪个是对的?
TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("Mountain Standard Time");
//UTC time
var utc1 = new DateTime(1990, 10, 28, 7, 0, 0); //This is start of daylight standard time.
var utc2 = new DateTime(1990, 10, 28, 8, 0, 0);
var utc3 = new DateTime(1990, 10, 28, 9, 0, 0);
utc1 = DateTime.SpecifyKind(utc1, DateTimeKind.Utc);
utc2 = DateTime.SpecifyKind(utc2, DateTimeKind.Utc);
utc3 = DateTime.SpecifyKind(utc3, DateTimeKind.Utc);
//Get the local time with adjustment for Daylight standard time, "fall back"
var local1 = TimeZoneInfo.ConvertTimeFromUtc(utc1, tz); //Returns 1am
var local2 = TimeZoneInfo.ConvertTimeFromUtc(utc2, tz); //Returns 1am. Should this be 2am?
var local3 = TimeZoneInfo.ConvertTimeFromUtc(utc3, tz); //Returns 2am