DateTimeOffset
と を使用する必要があると思いますTimeZoneInfo
。この記事、特にDateTimeOffset 値を使用した比較と算術演算セクションの 2 番目のコード スニペットが役立ちます。
そのコードでは、夏時間の DateTimeOffset インスタンスに時間が追加されており、結果は時間の変更を考慮していることがわかります。
編集:以下のコードは、上記の記事から取得したものです (コードはあなたが望むことをしませんが、夏時間を考慮してDateTimeOffset
使用されていることを示しています:TimeZoneInfo
public static void Main()
{
DateTime generalTime = new DateTime(2008, 3, 9, 1, 30, 0);
const string tzName = "Central Standard Time";
TimeSpan twoAndAHalfHours = new TimeSpan(2, 30, 0);
// Instantiate DateTimeOffset value to have correct CST offset
try
{
DateTimeOffset centralTime1 = new DateTimeOffset(generalTime,
TimeZoneInfo.FindSystemTimeZoneById(tzName).GetUtcOffset(generalTime));
// Add two and a half hours
DateTimeOffset centralTime2 = centralTime1.Add(twoAndAHalfHours);
// Display result
Console.WriteLine("{0} + {1} hours = {2}", centralTime1,
twoAndAHalfHours.ToString(),
centralTime2);
}
catch (TimeZoneNotFoundException)
{
Console.WriteLine("Unable to retrieve Central Standard Time zone information.");
}
}
// The example displays the following output to the console:
// 3/9/2008 1:30:00 AM -06:00 + 02:30:00 hours = 3/9/2008 4:00:00 AM -06:00