本文整理汇总了C#中LocalDateTime.WithOffset方法的典型用法代码示例。如果您正苦于以下问题:C# LocalDateTime.WithOffset方法的具体用法?C# LocalDateTime.WithOffset怎么用?C# LocalDateTime.WithOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocalDateTime
的用法示例。
在下文中一共展示了LocalDateTime.WithOffset方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BinarySerialization_NonIso
public void BinarySerialization_NonIso()
{
DateTimeZoneProviders.Serialization = DateTimeZoneProviders.Tzdb;
var zone = DateTimeZoneProviders.Tzdb["America/New_York"];
var localDateTime = new LocalDateTime(2013, 6, 12, 17, 53, 23, CalendarSystem.Julian);
var value = new ZonedDateTime(localDateTime.WithOffset(Offset.FromHours(-4)), zone);
TestHelper.AssertBinaryRoundtrip(value);
}
示例2: XmlSerialization_NonIso
public void XmlSerialization_NonIso()
{
DateTimeZoneProviders.Serialization = DateTimeZoneProviders.Tzdb;
var zone = DateTimeZoneProviders.Tzdb["America/New_York"];
var localDateTime = new LocalDateTime(2013, 6, 12, 17, 53, 23, CalendarSystem.Julian);
var value = new ZonedDateTime(localDateTime.WithOffset(Offset.FromHours(-4)), zone);
TestHelper.AssertXmlRoundtrip(value,
"<value zone=\"America/New_York\" calendar=\"Julian\">2013-06-12T17:53:23-04</value>");
}
示例3: WithOffset
public void WithOffset()
{
var offset = Offset.FromHoursAndMinutes(5, 10);
var localDateTime = new LocalDateTime(2009, 12, 22, 21, 39, 30);
var offsetDateTime = localDateTime.WithOffset(offset);
Assert.AreEqual(localDateTime, offsetDateTime.LocalDateTime);
Assert.AreEqual(offset, offsetDateTime.Offset);
}
示例4: CreateResolver_Unambiguous
public void CreateResolver_Unambiguous()
{
AmbiguousTimeResolver ambiguityResolver = (earlier, later) => { Assert.Fail("Shouldn't be called"); return default(ZonedDateTime); };
SkippedTimeResolver skippedTimeResolver = (local, zone, before, after) => { Assert.Fail("Shouldn't be called"); return default(ZonedDateTime); };
var resolver = Resolvers.CreateMappingResolver(ambiguityResolver, skippedTimeResolver);
LocalDateTime localTime = new LocalDateTime(1900, 1, 1, 0, 0);
var resolved = resolver(GapZone.MapLocal(localTime));
Assert.AreEqual(new ZonedDateTime(localTime.WithOffset(GapZone.EarlyInterval.WallOffset), GapZone), resolved);
}
示例5: more_offset_stuff
public void more_offset_stuff() {
var offset = Offset.FromHours(5);
var localTime = new LocalDateTime(2012, 1, 2, 3, 4, 5);
var localTimeWithOffset = localTime.WithOffset(offset);
}