当前位置: 首页>>代码示例>>C#>>正文


C# LocalDateTime.WithOffset方法代码示例

本文整理汇总了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);
 }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:8,代码来源:ZonedDateTimeTest.cs

示例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>");
 }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:9,代码来源:ZonedDateTimeTest.cs

示例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);
 }
开发者ID:nicklbailey,项目名称:nodatime,代码行数:8,代码来源:LocalDateTimeTest.cs

示例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);
        }
开发者ID:nicklbailey,项目名称:nodatime,代码行数:10,代码来源:ResolversTest.cs

示例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);
    
 }
开发者ID:heynickc,项目名称:noda_datetimes_deepdive,代码行数:6,代码来源:WithNodaTime.cs


注:本文中的LocalDateTime.WithOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。