Exemple #1
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));
        }
Exemple #2
0
        public ChronoPeriod Until(ChronoLocalDate endDate)
        {
            Period period = IsoDate.Until(endDate);

            return(Chronology.period(period.Years, period.Months, period.Days));
        }