public TemporalAccessorAnonymousInnerClassHelper(TemporalAccessor temporal, Chronology effectiveChrono, ZoneId effectiveZone, ChronoLocalDate effectiveDate)
 {
     this.Temporal        = temporal;
     this.EffectiveChrono = effectiveChrono;
     this.EffectiveZone   = effectiveZone;
     this.EffectiveDate   = effectiveDate;
 }
Esempio n. 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: static ChronoLocalDateTime<?> readExternal(java.io.ObjectInput in) throws java.io.IOException, ClassNotFoundException
//JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
        internal static ChronoLocalDateTime <?> ReadExternal(ObjectInput @in)
        {
            ChronoLocalDate date = (ChronoLocalDate)@in.ReadObject();
            LocalTime       time = (LocalTime)@in.ReadObject();

            return(date.atTime(time));
        }
Esempio n. 3
0
 private void ResolvePeriod()
 {
     // add whole days if we have both date and time
     if (Date != java.time.temporal.TemporalAccessor_Fields.Null && Time != java.time.temporal.TemporalAccessor_Fields.Null && ExcessDays.Zero == false)
     {
         Date       = Date.plus(ExcessDays);
         ExcessDays = Period.ZERO;
     }
 }
Esempio n. 4
0
        //-----------------------------------------------------------------------
        public long Until(Temporal endExclusive, TemporalUnit unit)
        {
            Objects.RequireNonNull(endExclusive, "endExclusive");
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") ChronoLocalDateTime<D> end = (ChronoLocalDateTime<D>) getChronology().localDateTime(endExclusive);
            ChronoLocalDateTime <D> end = (ChronoLocalDateTime <D>)Chronology.localDateTime(endExclusive);

            if (unit is ChronoUnit)
            {
                if (unit.TimeBased)
                {
                    long amount = end.getLong(EPOCH_DAY) - Date.GetLong(EPOCH_DAY);
                    switch ((ChronoUnit)unit)
                    {
                    case NANOS:
                        amount = Math.MultiplyExact(amount, NANOS_PER_DAY);
                        break;

                    case MICROS:
                        amount = Math.MultiplyExact(amount, MICROS_PER_DAY);
                        break;

                    case MILLIS:
                        amount = Math.MultiplyExact(amount, MILLIS_PER_DAY);
                        break;

                    case SECONDS:
                        amount = Math.MultiplyExact(amount, SECONDS_PER_DAY);
                        break;

                    case MINUTES:
                        amount = Math.MultiplyExact(amount, MINUTES_PER_DAY);
                        break;

                    case HOURS:
                        amount = Math.MultiplyExact(amount, HOURS_PER_DAY);
                        break;

                    case HALF_DAYS:
                        amount = Math.MultiplyExact(amount, 2);
                        break;
                    }
                    return(Math.AddExact(amount, Time.Until(end.ToLocalTime(), unit)));
                }
                ChronoLocalDate endDate = end.ToLocalDate();
                if (end.ToLocalTime().IsBefore(Time))
                {
                    endDate = endDate.minus(1, ChronoUnit.DAYS);
                }
                return(Date.Until(endDate, unit));
            }
            Objects.RequireNonNull(unit, "unit");
            return(unit.Between(this, end));
        }
Esempio n. 5
0
        private long MonthsUntil(ChronoLocalDate end)
        {
            ValueRange java.time.temporal.TemporalAccessor_Fields.Range = Chronology.Range(MONTH_OF_YEAR);

            if (java.time.temporal.TemporalAccessor_Fields.Range.Maximum != 12)
            {
                throw new IllegalStateException("ChronoLocalDateImpl only supports Chronologies with 12 months per year");
            }
            long packed1 = GetLong(PROLEPTIC_MONTH) * 32L + get(DAY_OF_MONTH);             // no overflow
            long packed2 = end.GetLong(PROLEPTIC_MONTH) * 32L + end.get(DAY_OF_MONTH);     // no overflow

            return((packed2 - packed1) / 32);
        }
Esempio n. 6
0
 private void UpdateCheckConflict(ChronoLocalDate cld)
 {
     if (Date != java.time.temporal.TemporalAccessor_Fields.Null)
     {
         if (cld != java.time.temporal.TemporalAccessor_Fields.Null && Date.Equals(cld) == false)
         {
             throw new DateTimeException("Conflict found: Fields resolved to two different dates: " + Date + " " + cld);
         }
     }
     else if (cld != java.time.temporal.TemporalAccessor_Fields.Null)
     {
         if (Chrono.Equals(cld.Chronology) == false)
         {
             throw new DateTimeException("ChronoLocalDate must use the effective parsed chronology: " + Chrono);
         }
         Date = cld;
     }
 }
Esempio n. 7
0
        //-----------------------------------------------------------------------
        public virtual long Until(Temporal endExclusive, TemporalUnit unit)
        {
            Objects.RequireNonNull(endExclusive, "endExclusive");
            ChronoLocalDate end = Chronology.Date(endExclusive);

            if (unit is ChronoUnit)
            {
                switch ((ChronoUnit)unit)
                {
                case DAYS:
                    return(DaysUntil(end));

                case WEEKS:
                    return(DaysUntil(end) / 7);

                case MONTHS:
                    return(MonthsUntil(end));

                case YEARS:
                    return(MonthsUntil(end) / 12);

                case DECADES:
                    return(MonthsUntil(end) / 120);

                case CENTURIES:
                    return(MonthsUntil(end) / 1200);

                case MILLENNIA:
                    return(MonthsUntil(end) / 12000);

                case ERAS:
                    return(end.GetLong(ERA) - GetLong(ERA));
                }
                throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit);
            }
            Objects.RequireNonNull(unit, "unit");
            return(unit.Between(this, end));
        }
Esempio n. 8
0
        public ChronoPeriod Until(ChronoLocalDate endDate)
        {
            // TODO: untested
            HijrahDate end         = Chronology.Date(endDate);
            long       totalMonths = (end.ProlepticYear - this.ProlepticYear) * 12 + (end.MonthOfYear - this.MonthOfYear);       // safe
            int        days        = end.DayOfMonth - this.DayOfMonth;

            if (totalMonths > 0 && days < 0)
            {
                totalMonths--;
                HijrahDate calcDate = this.PlusMonths(totalMonths);
                days = (int)(end.ToEpochDay() - calcDate.ToEpochDay());                 // safe
            }
            else if (totalMonths < 0 && days > 0)
            {
                totalMonths++;
                days -= end.LengthOfMonth();
            }
            long years  = totalMonths / 12;            // safe
            int  months = (int)(totalMonths % 12);     // safe

            return(Chronology.period(Math.ToIntExact(years), months, days));
        }
Esempio n. 9
0
        public ChronoPeriod Until(ChronoLocalDate endDate)
        {
            Period period = IsoDate.Until(endDate);

            return(Chronology.period(period.Years, period.Months, period.Days));
        }
Esempio n. 10
0
 private long DaysUntil(ChronoLocalDate end)
 {
     return(end.toEpochDay() - toEpochDay());            // no overflow
 }
Esempio n. 11
0
 public abstract ChronoPeriod Until(ChronoLocalDate endDateExclusive);