Exemplo n.º 1
0
 /// <summary>
 /// Internal constructor from pre-validated values.
 /// </summary>
 internal ZonedDateTime(OffsetDateTime offsetDateTime, DateTimeZone zone)
 {
     this.offsetDateTime = offsetDateTime;
     this.zone           = zone;
 }
Exemplo n.º 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)));
 }
Exemplo n.º 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));
 }
Exemplo n.º 4
0
 /// <inheritdoc />
 public override bool Equals(OffsetDateTime x, OffsetDateTime y) =>
 x.ToElapsedTimeSinceEpoch() == y.ToElapsedTimeSinceEpoch();
Exemplo n.º 5
0
 /// <inheritdoc />
 public override int GetHashCode(OffsetDateTime obj) => obj.ToElapsedTimeSinceEpoch().GetHashCode();
Exemplo n.º 6
0
 /// <inheritdoc />
 public override int GetHashCode(OffsetDateTime obj) => HashCodeHelper.Hash(obj.yearMonthDayCalendar, obj.NanosecondOfDay);
Exemplo n.º 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());
Exemplo n.º 8
0
 /// <inheritdoc />
 public override bool Equals(OffsetDateTime x, OffsetDateTime y) =>
 x.yearMonthDayCalendar == y.yearMonthDayCalendar && x.NanosecondOfDay == y.NanosecondOfDay;
Exemplo n.º 9
0
 /// <inheritdoc />
 public override int Compare(OffsetDateTime x, OffsetDateTime y)
 {
     return(x.ToInstant().CompareTo(y.ToInstant()));
 }
Exemplo n.º 10
0
 /// <inheritdoc />
 public override int Compare(OffsetDateTime x, OffsetDateTime y)
 {
     return(x.localDateTime.LocalInstant.CompareTo(y.localDateTime.LocalInstant));
 }
Exemplo n.º 11
0
 /// <inheritdoc />
 public override int GetHashCode(OffsetDateTime obj) => HashCodeHelper.Hash(obj.localDate, obj.NanosecondOfDay);
Exemplo n.º 12
0
 /// <inheritdoc />
 public override bool Equals(OffsetDateTime x, OffsetDateTime y) =>
 x.localDate == y.localDate && x.NanosecondOfDay == y.NanosecondOfDay;