package o; import java.io.Serializable; import java.util.Arrays; import java.util.List; import java.util.Map; import org.threeten.bp.DateTimeException; /* loaded from: classes.dex */ public final class gsV extends gsR implements Serializable { public static final gsV INSTANCE = new gsV(); private static final long serialVersionUID = -1440403870442975015L; @Override // o.gsR public final /* bridge */ /* synthetic */ gsJ resolveDate(Map map, gtA gta) { return resolveDate((Map) map, gta); } private gsV() { } @Override // o.gsR public final C15520gsp date(gsY gsy, int i, int i2, int i3) { return date(prolepticYear(gsy, i), i2, i3); } @Override // o.gsR public final C15520gsp date(int i, int i2, int i3) { return C15520gsp.of(i, i2, i3); } @Override // o.gsR public final C15520gsp dateYearDay(gsY gsy, int i, int i2) { return dateYearDay(prolepticYear(gsy, i), i2); } @Override // o.gsR public final C15520gsp dateYearDay(int i, int i2) { return C15520gsp.ofYearDay(i, i2); } @Override // o.gsR public final C15520gsp dateEpochDay(long j) { return C15520gsp.ofEpochDay(j); } @Override // o.gsR public final C15520gsp date(gtK gtk) { return C15520gsp.from(gtk); } @Override // o.gsR public final C15522gsr localDateTime(gtK gtk) { return C15522gsr.from(gtk); } @Override // o.gsR public final gsN zonedDateTime(gtK gtk) { return gsN.from(gtk); } @Override // o.gsR public final gsN zonedDateTime(C15523gss c15523gss, AbstractC15502gsH abstractC15502gsH) { return gsN.ofInstant(c15523gss, abstractC15502gsH); } @Override // o.gsR public final C15520gsp dateNow() { return dateNow(AbstractC15514gsj.systemDefaultZone()); } @Override // o.gsR public final C15520gsp dateNow(AbstractC15502gsH abstractC15502gsH) { return dateNow(AbstractC15514gsj.system(abstractC15502gsH)); } @Override // o.gsR public final C15520gsp dateNow(AbstractC15514gsj abstractC15514gsj) { gtG.requireNonNull(abstractC15514gsj, "clock"); return date((gtK) C15520gsp.now(abstractC15514gsj)); } @Override // o.gsR public final boolean isLeapYear(long j) { return (3 & j) == 0 && (j % 100 != 0 || j % 400 == 0); } @Override // o.gsR public final int prolepticYear(gsY gsy, int i) { if (gsy instanceof EnumC15541gtb) { return gsy != EnumC15541gtb.CE ? 1 - i : i; } throw new ClassCastException("Era must be IsoEra"); } @Override // o.gsR public final EnumC15541gtb eraOf(int i) { return EnumC15541gtb.of(i); } @Override // o.gsR public final List eras() { return Arrays.asList(EnumC15541gtb.values()); } @Override // o.gsR public final gtT range(EnumC15534gtD enumC15534gtD) { return enumC15534gtD.range(); } @Override // o.gsR public final C15520gsp resolveDate(Map map, gtA gta) { if (map.containsKey(EnumC15534gtD.EPOCH_DAY)) { return C15520gsp.ofEpochDay(map.remove(EnumC15534gtD.EPOCH_DAY).longValue()); } Long remove = map.remove(EnumC15534gtD.PROLEPTIC_MONTH); if (remove != null) { if (gta != gtA.LENIENT) { EnumC15534gtD.PROLEPTIC_MONTH.checkValidValue(remove.longValue()); } updateResolveMap(map, EnumC15534gtD.MONTH_OF_YEAR, gtG.floorMod(remove.longValue(), 12) + 1); updateResolveMap(map, EnumC15534gtD.YEAR, gtG.floorDiv(remove.longValue(), 12L)); } Long remove2 = map.remove(EnumC15534gtD.YEAR_OF_ERA); if (remove2 != null) { if (gta != gtA.LENIENT) { EnumC15534gtD.YEAR_OF_ERA.checkValidValue(remove2.longValue()); } Long remove3 = map.remove(EnumC15534gtD.ERA); if (remove3 == null) { Long l = map.get(EnumC15534gtD.YEAR); if (gta != gtA.STRICT) { updateResolveMap(map, EnumC15534gtD.YEAR, (l == null || l.longValue() > 0) ? remove2.longValue() : gtG.safeSubtract(1L, remove2.longValue())); } else if (l != null) { updateResolveMap(map, EnumC15534gtD.YEAR, l.longValue() > 0 ? remove2.longValue() : gtG.safeSubtract(1L, remove2.longValue())); } else { map.put(EnumC15534gtD.YEAR_OF_ERA, remove2); } } else if (remove3.longValue() == 1) { updateResolveMap(map, EnumC15534gtD.YEAR, remove2.longValue()); } else if (remove3.longValue() == 0) { updateResolveMap(map, EnumC15534gtD.YEAR, gtG.safeSubtract(1L, remove2.longValue())); } else { throw new DateTimeException("Invalid value for era: ".concat(String.valueOf(remove3))); } } else if (map.containsKey(EnumC15534gtD.ERA)) { EnumC15534gtD.ERA.checkValidValue(map.get(EnumC15534gtD.ERA).longValue()); } if (!map.containsKey(EnumC15534gtD.YEAR)) { return null; } if (map.containsKey(EnumC15534gtD.MONTH_OF_YEAR)) { if (map.containsKey(EnumC15534gtD.DAY_OF_MONTH)) { int checkValidIntValue = EnumC15534gtD.YEAR.checkValidIntValue(map.remove(EnumC15534gtD.YEAR).longValue()); int safeToInt = gtG.safeToInt(map.remove(EnumC15534gtD.MONTH_OF_YEAR).longValue()); int safeToInt2 = gtG.safeToInt(map.remove(EnumC15534gtD.DAY_OF_MONTH).longValue()); if (gta == gtA.LENIENT) { return C15520gsp.of(checkValidIntValue, 1, 1).plusMonths(gtG.safeSubtract(safeToInt, 1)).plusDays(gtG.safeSubtract(safeToInt2, 1)); } if (gta == gtA.SMART) { EnumC15534gtD.DAY_OF_MONTH.checkValidValue(safeToInt2); if (safeToInt == 4 || safeToInt == 6 || safeToInt == 9 || safeToInt == 11) { safeToInt2 = Math.min(safeToInt2, 30); } else if (safeToInt == 2) { safeToInt2 = Math.min(safeToInt2, EnumC15528gsx.FEBRUARY.length(gsF.isLeap(checkValidIntValue))); } return C15520gsp.of(checkValidIntValue, safeToInt, safeToInt2); } return C15520gsp.of(checkValidIntValue, safeToInt, safeToInt2); } if (map.containsKey(EnumC15534gtD.ALIGNED_WEEK_OF_MONTH)) { if (map.containsKey(EnumC15534gtD.ALIGNED_DAY_OF_WEEK_IN_MONTH)) { int checkValidIntValue2 = EnumC15534gtD.YEAR.checkValidIntValue(map.remove(EnumC15534gtD.YEAR).longValue()); if (gta == gtA.LENIENT) { return C15520gsp.of(checkValidIntValue2, 1, 1).plusMonths(gtG.safeSubtract(map.remove(EnumC15534gtD.MONTH_OF_YEAR).longValue(), 1L)).plusWeeks(gtG.safeSubtract(map.remove(EnumC15534gtD.ALIGNED_WEEK_OF_MONTH).longValue(), 1L)).plusDays(gtG.safeSubtract(map.remove(EnumC15534gtD.ALIGNED_DAY_OF_WEEK_IN_MONTH).longValue(), 1L)); } int checkValidIntValue3 = EnumC15534gtD.MONTH_OF_YEAR.checkValidIntValue(map.remove(EnumC15534gtD.MONTH_OF_YEAR).longValue()); C15520gsp plusDays = C15520gsp.of(checkValidIntValue2, checkValidIntValue3, 1).plusDays(((EnumC15534gtD.ALIGNED_WEEK_OF_MONTH.checkValidIntValue(map.remove(EnumC15534gtD.ALIGNED_WEEK_OF_MONTH).longValue()) - 1) * 7) + (EnumC15534gtD.ALIGNED_DAY_OF_WEEK_IN_MONTH.checkValidIntValue(map.remove(EnumC15534gtD.ALIGNED_DAY_OF_WEEK_IN_MONTH).longValue()) - 1)); if (gta != gtA.STRICT || plusDays.get(EnumC15534gtD.MONTH_OF_YEAR) == checkValidIntValue3) { return plusDays; } throw new DateTimeException("Strict mode rejected date parsed to a different month"); } if (map.containsKey(EnumC15534gtD.DAY_OF_WEEK)) { int checkValidIntValue4 = EnumC15534gtD.YEAR.checkValidIntValue(map.remove(EnumC15534gtD.YEAR).longValue()); if (gta == gtA.LENIENT) { return C15520gsp.of(checkValidIntValue4, 1, 1).plusMonths(gtG.safeSubtract(map.remove(EnumC15534gtD.MONTH_OF_YEAR).longValue(), 1L)).plusWeeks(gtG.safeSubtract(map.remove(EnumC15534gtD.ALIGNED_WEEK_OF_MONTH).longValue(), 1L)).plusDays(gtG.safeSubtract(map.remove(EnumC15534gtD.DAY_OF_WEEK).longValue(), 1L)); } int checkValidIntValue5 = EnumC15534gtD.MONTH_OF_YEAR.checkValidIntValue(map.remove(EnumC15534gtD.MONTH_OF_YEAR).longValue()); C15520gsp with = C15520gsp.of(checkValidIntValue4, checkValidIntValue5, 1).plusWeeks(EnumC15534gtD.ALIGNED_WEEK_OF_MONTH.checkValidIntValue(map.remove(EnumC15534gtD.ALIGNED_WEEK_OF_MONTH).longValue()) - 1).with(gtO.nextOrSame(EnumC15515gsk.of(EnumC15534gtD.DAY_OF_WEEK.checkValidIntValue(map.remove(EnumC15534gtD.DAY_OF_WEEK).longValue())))); if (gta != gtA.STRICT || with.get(EnumC15534gtD.MONTH_OF_YEAR) == checkValidIntValue5) { return with; } throw new DateTimeException("Strict mode rejected date parsed to a different month"); } } } if (map.containsKey(EnumC15534gtD.DAY_OF_YEAR)) { int checkValidIntValue6 = EnumC15534gtD.YEAR.checkValidIntValue(map.remove(EnumC15534gtD.YEAR).longValue()); if (gta == gtA.LENIENT) { return C15520gsp.ofYearDay(checkValidIntValue6, 1).plusDays(gtG.safeSubtract(map.remove(EnumC15534gtD.DAY_OF_YEAR).longValue(), 1L)); } return C15520gsp.ofYearDay(checkValidIntValue6, EnumC15534gtD.DAY_OF_YEAR.checkValidIntValue(map.remove(EnumC15534gtD.DAY_OF_YEAR).longValue())); } if (!map.containsKey(EnumC15534gtD.ALIGNED_WEEK_OF_YEAR)) { return null; } if (map.containsKey(EnumC15534gtD.ALIGNED_DAY_OF_WEEK_IN_YEAR)) { int checkValidIntValue7 = EnumC15534gtD.YEAR.checkValidIntValue(map.remove(EnumC15534gtD.YEAR).longValue()); if (gta == gtA.LENIENT) { return C15520gsp.of(checkValidIntValue7, 1, 1).plusWeeks(gtG.safeSubtract(map.remove(EnumC15534gtD.ALIGNED_WEEK_OF_YEAR).longValue(), 1L)).plusDays(gtG.safeSubtract(map.remove(EnumC15534gtD.ALIGNED_DAY_OF_WEEK_IN_YEAR).longValue(), 1L)); } C15520gsp plusDays2 = C15520gsp.of(checkValidIntValue7, 1, 1).plusDays(((EnumC15534gtD.ALIGNED_WEEK_OF_YEAR.checkValidIntValue(map.remove(EnumC15534gtD.ALIGNED_WEEK_OF_YEAR).longValue()) - 1) * 7) + (EnumC15534gtD.ALIGNED_DAY_OF_WEEK_IN_YEAR.checkValidIntValue(map.remove(EnumC15534gtD.ALIGNED_DAY_OF_WEEK_IN_YEAR).longValue()) - 1)); if (gta != gtA.STRICT || plusDays2.get(EnumC15534gtD.YEAR) == checkValidIntValue7) { return plusDays2; } throw new DateTimeException("Strict mode rejected date parsed to a different year"); } if (!map.containsKey(EnumC15534gtD.DAY_OF_WEEK)) { return null; } int checkValidIntValue8 = EnumC15534gtD.YEAR.checkValidIntValue(map.remove(EnumC15534gtD.YEAR).longValue()); if (gta == gtA.LENIENT) { return C15520gsp.of(checkValidIntValue8, 1, 1).plusWeeks(gtG.safeSubtract(map.remove(EnumC15534gtD.ALIGNED_WEEK_OF_YEAR).longValue(), 1L)).plusDays(gtG.safeSubtract(map.remove(EnumC15534gtD.DAY_OF_WEEK).longValue(), 1L)); } C15520gsp with2 = C15520gsp.of(checkValidIntValue8, 1, 1).plusWeeks(EnumC15534gtD.ALIGNED_WEEK_OF_YEAR.checkValidIntValue(map.remove(EnumC15534gtD.ALIGNED_WEEK_OF_YEAR).longValue()) - 1).with(gtO.nextOrSame(EnumC15515gsk.of(EnumC15534gtD.DAY_OF_WEEK.checkValidIntValue(map.remove(EnumC15534gtD.DAY_OF_WEEK).longValue())))); if (gta != gtA.STRICT || with2.get(EnumC15534gtD.YEAR) == checkValidIntValue8) { return with2; } throw new DateTimeException("Strict mode rejected date parsed to a different month"); } @Override // o.gsR public final String getId() { return "ISO"; } @Override // o.gsR public final String getCalendarType() { return "iso8601"; } private Object readResolve() { return INSTANCE; } }