本文整理汇总了C#中LocalTime类的典型用法代码示例。如果您正苦于以下问题:C# LocalTime类的具体用法?C# LocalTime怎么用?C# LocalTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LocalTime类属于命名空间,在下文中一共展示了LocalTime类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: PeriodAddition_MethodEquivalents
public void PeriodAddition_MethodEquivalents()
{
LocalTime start = new LocalTime(20, 30);
Period period = Period.FromHours(3) + Period.FromMinutes(10);
Assert.AreEqual(start + period, LocalTime.Add(start, period));
Assert.AreEqual(start + period, start.Plus(period));
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:7,代码来源:LocalTimeTest.Operators.cs
示例2: LocalNow
public ISettableClock LocalNow(LocalTime time)
{
_timeZone = time.TimeZone;
_time = time.UtcTime;
return this;
}
开发者ID:rasupit,项目名称:fubucore,代码行数:7,代码来源:ISettableClock.cs
示例3: CombineWithTime
public void CombineWithTime()
{
LocalDate date = new LocalDate(2010, 6, 16);
LocalTime time = new LocalTime(16, 20);
LocalDateTime dateTime = date + time;
Assert.AreEqual(new LocalDateTime(2010, 6, 16, 16, 20, 0), dateTime);
}
开发者ID:KonstantinDavidov,项目名称:nodatime,代码行数:7,代码来源:LocalDateDemo.cs
示例4: add
public void add()
{
var time = new LocalTime(DateTime.Today.AddHours(8), TimeZoneInfo.Local);
var halfHourLater = time.Add("0800".ToTime());
halfHourLater.Time.ShouldEqual(DateTime.Today.AddHours(16));
}
开发者ID:hartez,项目名称:fubucore,代码行数:7,代码来源:LocalTimeTester.cs
示例5: CombineWithTime
public void CombineWithTime()
{
LocalDate date = new LocalDate(2010, 6, 16);
LocalTime time = new LocalTime(16, 20, 0);
LocalDateTime dateTime = date + time;
Assert.AreEqual("ISO: 2010-06-16T16:20:00 LOC", dateTime.ToString());
}
开发者ID:manirana007,项目名称:NodaTime,代码行数:7,代码来源:LocalDateDemo.cs
示例6: PlusHours_CrossingDayBoundary
public void PlusHours_CrossingDayBoundary()
{
LocalTime start = new LocalTime(12, 15, 8);
LocalTime expected = new LocalTime(8, 15, 8);
Assert.AreEqual(expected, start.PlusHours(20));
Assert.AreEqual(start, start.PlusHours(20).PlusHours(-20));
}
开发者ID:ivandrofly,项目名称:nodatime,代码行数:7,代码来源:LocalTimeTest.Pseudomutators.cs
示例7: Subtraction_WithPeriod
public void Subtraction_WithPeriod()
{
LocalTime start = new LocalTime(5, 30, 1);
Period period = Period.FromHours(2) + Period.FromSeconds(1);
LocalTime expected = new LocalTime(3, 30, 0);
Assert.AreEqual(expected, start - period);
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:7,代码来源:LocalTimeTest.Operators.cs
示例8: Subtraction_WrapsAtMidnight
public void Subtraction_WrapsAtMidnight()
{
LocalTime start = new LocalTime(1, 0, 0);
Period period = Period.FromHours(3);
LocalTime expected = new LocalTime(22, 0, 0);
Assert.AreEqual(expected, start - period);
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:7,代码来源:LocalTimeTest.Operators.cs
示例9: Subtraction_PeriodWithTime
public void Subtraction_PeriodWithTime()
{
LocalTime time = new LocalTime(20, 30);
Period period = Period.FromDays(1);
// Use method not operator here to form a valid statement
Assert.Throws<ArgumentException>(() => LocalTime.Subtract(time, period));
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:7,代码来源:LocalTimeTest.Operators.cs
示例10: Flights_One_Way
public async Task Flights_One_Way()
{
var departureDate = Instant.FromDateTimeUtc(DateTime.UtcNow).InUtc().Date.PlusMonths(1);
var outboundDepartureStartTime = new LocalTime(8, 0, 0);
var outboundDepartureEndTime = new LocalTime(12, 0, 0);
const int maxStops = 2;
const int maxDuration = 14 * 60;
var itineraries = await Scanner.QueryFlight(new FlightQuerySettings(
new FlightRequestSettings(
Location.FromString("GVA-sky"),
Location.FromString("JFK-sky"),
departureDate),
new FlightResponseSettings(
sortOrder: SortOrder.Descending,
sortType: SortType.Price,
maxStops: maxStops,
maxDuration: maxDuration,
outboundDepartureStartTime: outboundDepartureStartTime,
outboundDepartureEndTime: outboundDepartureEndTime)));
Assert.IsTrue(itineraries.Count > 0);
foreach (var itinerary in itineraries)
{
Assert.IsNull(itinerary.InboundLeg);
}
}
开发者ID:jochenvanwylick,项目名称:SkyScanner,代码行数:28,代码来源:FlightTest.cs
示例11: PlusSeconds_Simple
public void PlusSeconds_Simple()
{
LocalTime start = new LocalTime(12, 15, 8);
LocalTime expectedForward = new LocalTime(12, 15, 18);
LocalTime expectedBackward = new LocalTime(12, 14, 58);
Assert.AreEqual(expectedForward, start.PlusSeconds(10));
Assert.AreEqual(expectedBackward, start.PlusSeconds(-10));
}
开发者ID:ivandrofly,项目名称:nodatime,代码行数:8,代码来源:LocalTimeTest.Pseudomutators.cs
示例12: PlusMilliseconds_Simple
public void PlusMilliseconds_Simple()
{
LocalTime start = new LocalTime(12, 15, 8, 300);
LocalTime expectedForward = new LocalTime(12, 15, 8, 700);
LocalTime expectedBackward = new LocalTime(12, 15, 7, 900);
Assert.AreEqual(expectedForward, start.PlusMilliseconds(400));
Assert.AreEqual(expectedBackward, start.PlusMilliseconds(-400));
}
开发者ID:ivandrofly,项目名称:nodatime,代码行数:8,代码来源:LocalTimeTest.Pseudomutators.cs
示例13: PlusTicks_Simple
public void PlusTicks_Simple()
{
LocalTime start = new LocalTime(12, 15, 8, 300, 7500);
LocalTime expectedForward = new LocalTime(12, 15, 8, 301, 1500);
LocalTime expectedBackward = new LocalTime(12, 15, 8, 300, 3500);
Assert.AreEqual(expectedForward, start.PlusTicks(4000));
Assert.AreEqual(expectedBackward, start.PlusTicks(-4000));
}
开发者ID:ivandrofly,项目名称:nodatime,代码行数:8,代码来源:LocalTimeTest.Pseudomutators.cs
示例14: greater_than_operator
public void greater_than_operator()
{
var time1 = new LocalTime(DateTime.Today.AddHours(8), TimeZoneInfo.Local);
var time2 = new LocalTime(DateTime.Today.AddHours(10), TimeZoneInfo.Local);
(time1 > time2).ShouldBeFalse();
(time2 > time1).ShouldBeTrue();
}
开发者ID:hartez,项目名称:fubucore,代码行数:8,代码来源:LocalTimeTester.cs
示例15: PlusMinutes_Simple
public void PlusMinutes_Simple()
{
LocalTime start = new LocalTime(12, 15, 8);
LocalTime expectedForward = new LocalTime(12, 17, 8);
LocalTime expectedBackward = new LocalTime(12, 13, 8);
Assert.AreEqual(expectedForward, start.PlusMinutes(2));
Assert.AreEqual(expectedBackward, start.PlusMinutes(-2));
}
开发者ID:ivandrofly,项目名称:nodatime,代码行数:8,代码来源:LocalTimeTest.Pseudomutators.cs
示例16: PlusHours_Simple
public void PlusHours_Simple()
{
LocalTime start = new LocalTime(12, 15, 8);
LocalTime expectedForward = new LocalTime(14, 15, 8);
LocalTime expectedBackward = new LocalTime(10, 15, 8);
Assert.AreEqual(expectedForward, start.PlusHours(2));
Assert.AreEqual(expectedBackward, start.PlusHours(-2));
}
开发者ID:ivandrofly,项目名称:nodatime,代码行数:8,代码来源:LocalTimeTest.Pseudomutators.cs
示例17: Complex
public Complex(IStorage stroage)
{
_Time = new LocalTime();
_Hall = new Hall();
_World = new World(LocalTime.Instance);
_Updater = new Utility.Updater<Utility.IUpdatable>();
_Storage = stroage;
}
开发者ID:kof1016,项目名称:Regulus,代码行数:8,代码来源:Complex.cs
示例18: PlusHours_CrossingSeveralDaysBoundary
public void PlusHours_CrossingSeveralDaysBoundary()
{
// Christmas day + 10 days and 1 hour
LocalTime start = new LocalTime(12, 15, 8);
LocalTime expected = new LocalTime(13, 15, 8);
Assert.AreEqual(expected, start.PlusHours(241));
Assert.AreEqual(start, start.PlusHours(241).PlusHours(-241));
}
开发者ID:ivandrofly,项目名称:nodatime,代码行数:8,代码来源:LocalTimeTest.Pseudomutators.cs
示例19: TimeOfDay_After1970
public void TimeOfDay_After1970()
{
LocalDateTime dateTime = new LocalDateTime(1975, 11, 8, 12, 5, 23);
LocalTime expected = new LocalTime(12, 5, 23);
Assert.AreEqual(expected, dateTime.TimeOfDay);
Assert.AreEqual(new LocalDateTime(1970, 1, 1, 12, 5, 23), dateTime.TimeOfDay.LocalDateTime);
}
开发者ID:manirana007,项目名称:NodaTime,代码行数:8,代码来源:LocalDateTimeTest.cs
示例20: create_local_time
public void create_local_time()
{
var time = new LocalTime(DateTime.Today.AddHours(8).ToUniversalTime(TimeZoneInfo.Local), TimeZoneInfo.Local);
time.Time.ShouldEqual(DateTime.Today.AddHours(8));
time.TimeOfDay.ShouldEqual("0800".ToTime());
time.Date.ShouldEqual(DateTime.Today.ToDate());
time.UtcTime.ShouldEqual(DateTime.Today.AddHours(8).ToUniversalTime(TimeZoneInfo.Local));
}
开发者ID:hartez,项目名称:fubucore,代码行数:9,代码来源:LocalTimeTester.cs
注:本文中的LocalTime类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论