示例#1
0
        int IComparable.CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            if (!(obj is DateTimeOffset))
            {
                throw new ArgumentException();
            }
            var other = (DateTimeOffset)obj;

            return(UtcDateTime.CompareTo(other.UtcDateTime));
        }
示例#2
0
        public int CompareTo(object obj)
        {
            if (obj is ZonedDateTime zonded)
            {
                return(CompareTo(zonded));
            }
            if (obj is DateTimeOffset offset)
            {
                return(UtcDateTime.CompareTo(offset.UtcDateTime));
            }
            if (!(obj is DateTime date))
            {
                throw new NotSupportedException();
            }

            if (date.Kind == DateTimeKind.Utc)
            {
                return(UtcDateTime.CompareTo(date));
            }

            return(UtcDateTime.CompareTo(DateTimeZone.ConvertTime(date, DateTimeZone.Local, DateTimeZone.Utc)));
        }
示例#3
0
 public int CompareTo(DateTimeOffset other)
 {
     return(UtcDateTime.CompareTo(other.UtcDateTime));
 }
示例#4
0
 public int CompareTo(ZonedDateTime other)
 {
     return(UtcDateTime.CompareTo(other.UtcDateTime));
 }