示例#1
0
 public override bool Equals(Value other)
 {
     if (other is DateTimeValue)
     {
         ZonedDateTime that = (( DateTimeValue )other)._value;
         bool          res  = _value.toLocalDateTime().Equals(that.toLocalDateTime());
         if (res)
         {
             ZoneId thisZone     = _value.Zone;
             ZoneId thatZone     = that.Zone;
             bool   thisIsOffset = thisZone is ZoneOffset;
             bool   thatIsOffset = thatZone is ZoneOffset;
             if (thisIsOffset && thatIsOffset)
             {
                 res = thisZone.Equals(thatZone);
             }
             else if (!thisIsOffset && !thatIsOffset)
             {
                 res = string.ReferenceEquals(TimeZones.map(thisZone.Id), TimeZones.map(thatZone.Id));
             }
             else
             {
                 res = false;
             }
         }
         return(res);
     }
     return(false);
 }
示例#2
0
        private int CompareNamedZonesWithMapping(ZoneId thisZone, ZoneId thatZone)
        {
            string thisZoneNormalized = TimeZones.Map(TimeZones.Map(thisZone.Id));
            string thatZoneNormalized = TimeZones.Map(TimeZones.Map(thatZone.Id));

            return(thisZoneNormalized.CompareTo(thatZoneNormalized));
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void weSupportDeletedZoneIdEastSaskatchewan()
        internal virtual void WeSupportDeletedZoneIdEastSaskatchewan()
        {
            try
            {
                short eastSaskatchewan = TimeZones.Map("Canada/East-Saskatchewan");
                assertThat("Our time zone table does not remap Canada/East-Saskatchewan to Canada/Saskatchewan", TimeZones.Map(eastSaskatchewan), equalTo("Canada/Saskatchewan"));
            }
            catch (System.ArgumentException)
            {
                fail("Our time zone table does not support Canada/East-Saskatchewan");
            }
        }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void weSupportAllJavaZoneIds()
        internal virtual void WeSupportAllJavaZoneIds()
        {
            ZoneId.AvailableZoneIds.forEach(s =>
            {
                short num = TimeZones.map(s);
                assertThat("Our time zone table does not have a mapping for " + s, num, greaterThanOrEqualTo(( short )0));

                string nameFromTable = TimeZones.Map(num);
                if (!s.Equals(nameFromTable))
                {
                    // The test is running on an older Java version and `s` has been removed since, thus it points to a different zone now.
                    // That zone should point to itself, however.
                    assertThat("Our time zone table has inconsistent mapping for " + nameFromTable, TimeZones.Map(TimeZones.Map(nameFromTable)), equalTo(nameFromTable));
                }
            });
        }
示例#5
0
        private DateTimeValue(ZonedDateTime value)
        {
            ZoneId zone = value.Zone;

            if (zone is ZoneOffset)
            {
                this._value = value;
            }
            else
            {
                // Do a 2-way lookup of the zone to make sure we only use the new name of renamed zones
                ZoneId mappedZone = ZoneId.of(TimeZones.Map(TimeZones.Map(zone.Id)));
                this._value = value.withZoneSameInstant(mappedZone);
            }
            this._epochSeconds = this._value.toEpochSecond();
        }