本文整理汇总了C#中LocalDateTime.Minus方法的典型用法代码示例。如果您正苦于以下问题:C# LocalDateTime.Minus方法的具体用法?C# LocalDateTime.Minus怎么用?C# LocalDateTime.Minus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocalDateTime
的用法示例。
在下文中一共展示了LocalDateTime.Minus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Subtraction_OffsetDateTime
public void Subtraction_OffsetDateTime()
{
// Test all three approaches... not bothering to check a different calendar,
// but we'll use two different offsets.
OffsetDateTime start = new LocalDateTime(2014, 08, 14, 6, 51).WithOffset(Offset.FromHours(1));
OffsetDateTime end = new LocalDateTime(2014, 08, 14, 18, 0).WithOffset(Offset.FromHours(4));
Duration expected = Duration.FromHours(8) + Duration.FromMinutes(9);
Assert.AreEqual(expected, end - start);
Assert.AreEqual(expected, end.Minus(start));
Assert.AreEqual(expected, OffsetDateTime.Subtract(end, start));
}
示例2: Operator_MethodEquivalents
public void Operator_MethodEquivalents()
{
LocalDateTime start = new LocalDateTime(2011, 1, 1, 15, 25, 30, 100, 5000);
Period period = Period.FromHours(1) + Period.FromDays(1);
LocalDateTime end = start + period;
Assert.AreEqual(start + period, LocalDateTime.Add(start, period));
Assert.AreEqual(start + period, start.Plus(period));
Assert.AreEqual(start - period, LocalDateTime.Subtract(start, period));
Assert.AreEqual(start - period, start.Minus(period));
Assert.AreEqual(period, end - start);
Assert.AreEqual(period, LocalDateTime.Subtract(end, start));
Assert.AreEqual(period, end.Minus(start));
}