本文整理汇总了C#中Instant.InUtc方法的典型用法代码示例。如果您正苦于以下问题:C# Instant.InUtc方法的具体用法?C# Instant.InUtc怎么用?C# Instant.InUtc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Instant
的用法示例。
在下文中一共展示了Instant.InUtc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateZoneEquality
private void ValidateZoneEquality(Instant instant, DateTimeZone nodaZone, TimeZoneInfo windowsZone)
{
// The BCL is basically broken (up to and including .NET 4.5.1 at least) around its interpretation
// of its own data around the new year. See http://codeblog.jonskeet.uk/2014/09/30/the-mysteries-of-bcl-time-zone-data/
// for details. We're not trying to emulate this behaviour.
// It's a lot *better* for .NET 4.6,
var utc = instant.InUtc();
if ((utc.Month == 12 && utc.Day == 31) || (utc.Month == 1 && utc.Day == 1))
{
return;
}
var interval = nodaZone.GetZoneInterval(instant);
// Check that the zone interval really represents a transition. It could be a change in
// wall offset, name, or the split between standard time and daylight savings for the interval.
if (interval.RawStart != Instant.BeforeMinValue)
{
var previousInterval = nodaZone.GetZoneInterval(interval.Start - Duration.Epsilon);
Assert.AreNotEqual(new {interval.WallOffset, interval.Name, interval.StandardOffset},
new {previousInterval.WallOffset, previousInterval.Name, previousInterval.StandardOffset},
"Non-transition from {0} to {1}", previousInterval, interval);
}
var nodaOffset = interval.WallOffset;
var windowsOffset = windowsZone.GetUtcOffset(instant.ToDateTimeUtc());
Assert.AreEqual(windowsOffset, nodaOffset.ToTimeSpan(), $"Incorrect offset at {instant} in interval {interval}");
var bclDaylight = windowsZone.IsDaylightSavingTime(instant.ToDateTimeUtc());
Assert.AreEqual(bclDaylight, interval.Savings != Offset.Zero,
$"At {instant}, BCL IsDaylightSavingTime={bclDaylight}; Noda savings={interval.Savings}");
}