示例#1
0
 /// <summary>
 /// Internal constructor from pre-validated values.
 /// </summary>
 internal ZonedDateTime(OffsetDateTime offsetDateTime, DateTimeZone zone)
 {
     this.offsetDateTime = offsetDateTime;
     this.zone           = zone;
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZonedDateTime"/> struct.
 /// </summary>
 /// <param name="instant">The instant.</param>
 /// <param name="zone">The time zone.</param>
 /// <param name="calendar">The calendar system.</param>
 public ZonedDateTime(Instant instant, DateTimeZone zone, CalendarSystem calendar)
 {
     this.zone      = Preconditions.CheckNotNull(zone, nameof(zone));
     offsetDateTime = new OffsetDateTime(instant, zone.GetUtcOffset(instant), Preconditions.CheckNotNull(calendar, nameof(calendar)));
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZonedDateTime" /> struct in the specified time zone
 /// and the ISO calendar.
 /// </summary>
 /// <param name="instant">The instant.</param>
 /// <param name="zone">The time zone.</param>
 public ZonedDateTime(Instant instant, DateTimeZone zone)
 {
     this.zone      = Preconditions.CheckNotNull(zone, nameof(zone));
     offsetDateTime = new OffsetDateTime(instant, zone.GetUtcOffset(instant));
 }
示例#4
0
 /// <inheritdoc />
 public override bool Equals(OffsetDateTime x, OffsetDateTime y) =>
 x.ToElapsedTimeSinceEpoch() == y.ToElapsedTimeSinceEpoch();
示例#5
0
 /// <inheritdoc />
 public override int GetHashCode(OffsetDateTime obj) => obj.ToElapsedTimeSinceEpoch().GetHashCode();
示例#6
0
 /// <inheritdoc />
 public override int GetHashCode(OffsetDateTime obj) => HashCodeHelper.Hash(obj.yearMonthDayCalendar, obj.NanosecondOfDay);
示例#7
0
 /// <inheritdoc />
 public override int Compare(OffsetDateTime x, OffsetDateTime y) =>
 // TODO(2.0): Optimize cases which are more than 2 days apart, by avoiding the arithmetic?
 x.ToElapsedTimeSinceEpoch().CompareTo(y.ToElapsedTimeSinceEpoch());
示例#8
0
 /// <inheritdoc />
 public override bool Equals(OffsetDateTime x, OffsetDateTime y) =>
 x.yearMonthDayCalendar == y.yearMonthDayCalendar && x.NanosecondOfDay == y.NanosecondOfDay;
示例#9
0
 /// <inheritdoc />
 public override int Compare(OffsetDateTime x, OffsetDateTime y)
 {
     return(x.ToInstant().CompareTo(y.ToInstant()));
 }
示例#10
0
 /// <inheritdoc />
 public override int Compare(OffsetDateTime x, OffsetDateTime y)
 {
     return(x.localDateTime.LocalInstant.CompareTo(y.localDateTime.LocalInstant));
 }
示例#11
0
 /// <inheritdoc />
 public override int GetHashCode(OffsetDateTime obj) => HashCodeHelper.Hash(obj.localDate, obj.NanosecondOfDay);
示例#12
0
 /// <inheritdoc />
 public override bool Equals(OffsetDateTime x, OffsetDateTime y) =>
 x.localDate == y.localDate && x.NanosecondOfDay == y.NanosecondOfDay;