本文整理汇总了C#中LocalTime类的典型用法代码示例。如果您正苦于以下问题:C# LocalTime类的具体用法?C# LocalTime怎么用?C# LocalTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LocalTime类属于命名空间,在下文中一共展示了LocalTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例2: LocalNow
public ISettableClock LocalNow(LocalTime time)
{
_timeZone = time.TimeZone;
_time = time.UtcTime;
return this;
}
示例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);
}
示例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));
}
示例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());
}
示例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));
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
}
示例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));
}
示例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));
}
示例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));
}
示例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();
}
示例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));
}