//----------------------------------------------------------------------- public override ValueRange java.time.temporal.TemporalAccessor_Fields.range(TemporalField field) { if (field is ChronoField) { if (IsSupported(field)) { ChronoField f = (ChronoField)field; switch (f) { case DAY_OF_MONTH: case DAY_OF_YEAR: case ALIGNED_WEEK_OF_MONTH: return(IsoDate.Range(field)); case YEAR_OF_ERA: { ValueRange java.time.temporal.TemporalAccessor_Fields.Range = YEAR.range(); long max = (ProlepticYear <= 0 ? -java.time.temporal.TemporalAccessor_Fields.Range.Minimum + 1 + YEARS_DIFFERENCE : java.time.temporal.TemporalAccessor_Fields.Range.Maximum - YEARS_DIFFERENCE); return(ValueRange.Of(1, max)); } } return(Chronology.Range(f)); } throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return(field.RangeRefinedBy(this)); }
public override ValueRange java.time.temporal.TemporalAccessor_Fields.range(TemporalField field) { if (field is ChronoField) { if (IsSupported(field)) { ChronoField f = (ChronoField)field; switch (f) { case DAY_OF_MONTH: return(ValueRange.Of(1, LengthOfMonth())); case DAY_OF_YEAR: return(ValueRange.Of(1, LengthOfYear())); case YEAR_OF_ERA: { DateTime jcal = DateTime.GetInstance(JapaneseChronology.LOCALE); jcal.set(DateTime.ERA, Era_Renamed.Value + JapaneseEra.ERA_OFFSET); jcal = new DateTime(YearOfEra, IsoDate.MonthValue - 1, IsoDate.DayOfMonth); return(ValueRange.Of(1, jcal.getActualMaximum(DateTime.YEAR))); } } return(Chronology.Range(f)); } throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return(field.RangeRefinedBy(this)); }
//----------------------------------------------------------------------- public override ValueRange java.time.temporal.TemporalAccessor_Fields.range(TemporalField field) { if (field is ChronoField) { if (IsSupported(field)) { ChronoField f = (ChronoField)field; switch (f) { case DAY_OF_MONTH: return(ValueRange.Of(1, LengthOfMonth())); case DAY_OF_YEAR: return(ValueRange.Of(1, LengthOfYear())); case ALIGNED_WEEK_OF_MONTH: // TODO return(ValueRange.Of(1, 5)); // TODO does the limited range of valid years cause years to // start/end part way through? that would affect range } return(Chronology.Range(f)); } throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return(field.RangeRefinedBy(this)); }
/// <summary> /// Calculates the range of months. /// </summary> /// <returns> the month range, -1 if not fixed range </returns> private long MonthRange() { ValueRange startRange = Chrono.Range(MONTH_OF_YEAR); if (startRange.Fixed && startRange.IntValue) { return(startRange.Maximum - startRange.Minimum + 1); } return(-1); }
//----------------------------------------------------------------------- public MinguoDate With(TemporalField field, long newValue) { if (field is ChronoField) { ChronoField f = (ChronoField)field; if (GetLong(f) == newValue) { return(this); } switch (f) { case PROLEPTIC_MONTH: Chronology.Range(f).CheckValidValue(newValue, f); return(PlusMonths(newValue - ProlepticMonth)); case YEAR_OF_ERA: case YEAR: case ERA: { int nvalue = Chronology.Range(f).CheckValidIntValue(newValue, f); switch (f) { case YEAR_OF_ERA: return(With(IsoDate.WithYear(ProlepticYear >= 1 ? nvalue + YEARS_DIFFERENCE : (1 - nvalue) + YEARS_DIFFERENCE))); case YEAR: return(With(IsoDate.WithYear(nvalue + YEARS_DIFFERENCE))); case ERA: return(With(IsoDate.WithYear((1 - ProlepticYear) + YEARS_DIFFERENCE))); } } break; } return(With(IsoDate.With(field, newValue))); } return(base.With(field, newValue)); }
//----------------------------------------------------------------------- public JapaneseDate With(TemporalField field, long newValue) { if (field is ChronoField) { ChronoField f = (ChronoField)field; if (GetLong(f) == newValue) // getLong() validates for supported fields { return(this); } switch (f) { case YEAR_OF_ERA: case YEAR: case ERA: { int nvalue = Chronology.Range(f).CheckValidIntValue(newValue, f); switch (f) { case YEAR_OF_ERA: return(this.WithYear(nvalue)); case YEAR: return(With(IsoDate.WithYear(nvalue))); case ERA: { return(this.WithYear(JapaneseEra.Of(nvalue), YearOfEra)); } } } break; } // YEAR, PROLEPTIC_MONTH and others are same as ISO return(With(IsoDate.With(field, newValue))); } return(base.With(field, newValue)); }