예제 #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;