package o; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; import org.threeten.bp.DateTimeException; /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.gtm, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public final class C15552gtm extends gtE implements Cloneable { gsR chrono; gsJ date; C15500gsA excessDays; final Map fieldValues = new HashMap(); boolean leapSecond; C15521gsq time; AbstractC15502gsH zone; public C15552gtm() { } public C15552gtm(InterfaceC15537gtP interfaceC15537gtP, long j) { addFieldValue(interfaceC15537gtP, j); } private Long getFieldValue0(InterfaceC15537gtP interfaceC15537gtP) { return this.fieldValues.get(interfaceC15537gtP); } final C15552gtm addFieldValue(InterfaceC15537gtP interfaceC15537gtP, long j) { gtG.requireNonNull(interfaceC15537gtP, "field"); Long fieldValue0 = getFieldValue0(interfaceC15537gtP); if (fieldValue0 != null && fieldValue0.longValue() != j) { StringBuilder sb = new StringBuilder("Conflict found: "); sb.append(interfaceC15537gtP); sb.append(" "); sb.append(fieldValue0); sb.append(" differs from "); sb.append(interfaceC15537gtP); sb.append(" "); sb.append(j); sb.append(": "); sb.append(this); throw new DateTimeException(sb.toString()); } return putFieldValue0(interfaceC15537gtP, j); } private C15552gtm putFieldValue0(InterfaceC15537gtP interfaceC15537gtP, long j) { this.fieldValues.put(interfaceC15537gtP, Long.valueOf(j)); return this; } public final C15552gtm resolve(gtA gta, Set set) { gsJ gsj; if (set != null) { this.fieldValues.keySet().retainAll(set); } mergeInstantFields(); mergeDate(gta); mergeTime(gta); if (resolveFields(gta)) { mergeInstantFields(); mergeDate(gta); mergeTime(gta); } resolveTimeInferZeroes(gta); crossCheck(); C15500gsA c15500gsA = this.excessDays; if (c15500gsA != null && !c15500gsA.isZero() && (gsj = this.date) != null && this.time != null) { this.date = gsj.plus((gtN) this.excessDays); this.excessDays = C15500gsA.ZERO; } resolveFractional(); resolveInstant(); return this; } private boolean resolveFields(gtA gta) { int i = 0; loop0: while (i < 100) { Iterator> it = this.fieldValues.entrySet().iterator(); while (it.hasNext()) { InterfaceC15537gtP key = it.next().getKey(); gtK resolve = key.resolve(this.fieldValues, this, gta); if (resolve != null) { if (resolve instanceof gsS) { gsS gss = (gsS) resolve; AbstractC15502gsH abstractC15502gsH = this.zone; if (abstractC15502gsH == null) { this.zone = gss.getZone(); } else if (!abstractC15502gsH.equals(gss.getZone())) { StringBuilder sb = new StringBuilder("ChronoZonedDateTime must use the effective parsed zone: "); sb.append(this.zone); throw new DateTimeException(sb.toString()); } resolve = gss.toLocalDateTime(); } if (resolve instanceof gsJ) { resolveMakeChanges(key, (gsJ) resolve); } else if (resolve instanceof C15521gsq) { resolveMakeChanges(key, (C15521gsq) resolve); } else if (resolve instanceof gsO) { gsO gso = (gsO) resolve; resolveMakeChanges(key, gso.toLocalDate()); resolveMakeChanges(key, gso.toLocalTime()); } else { StringBuilder sb2 = new StringBuilder("Unknown type: "); sb2.append(resolve.getClass().getName()); throw new DateTimeException(sb2.toString()); } } else if (!this.fieldValues.containsKey(key)) { break; } i++; } } if (i != 100) { return i > 0; } throw new DateTimeException("Badly written field"); } private void resolveMakeChanges(InterfaceC15537gtP interfaceC15537gtP, gsJ gsj) { if (!this.chrono.equals(gsj.getChronology())) { StringBuilder sb = new StringBuilder("ChronoLocalDate must use the effective parsed chronology: "); sb.append(this.chrono); throw new DateTimeException(sb.toString()); } long epochDay = gsj.toEpochDay(); Long put = this.fieldValues.put(EnumC15534gtD.EPOCH_DAY, Long.valueOf(epochDay)); if (put == null || put.longValue() == epochDay) { return; } StringBuilder sb2 = new StringBuilder("Conflict found: "); sb2.append(C15520gsp.ofEpochDay(put.longValue())); sb2.append(" differs from "); sb2.append(C15520gsp.ofEpochDay(epochDay)); sb2.append(" while resolving "); sb2.append(interfaceC15537gtP); throw new DateTimeException(sb2.toString()); } private void resolveMakeChanges(InterfaceC15537gtP interfaceC15537gtP, C15521gsq c15521gsq) { long nanoOfDay = c15521gsq.toNanoOfDay(); Long put = this.fieldValues.put(EnumC15534gtD.NANO_OF_DAY, Long.valueOf(nanoOfDay)); if (put == null || put.longValue() == nanoOfDay) { return; } StringBuilder sb = new StringBuilder("Conflict found: "); sb.append(C15521gsq.ofNanoOfDay(put.longValue())); sb.append(" differs from "); sb.append(c15521gsq); sb.append(" while resolving "); sb.append(interfaceC15537gtP); throw new DateTimeException(sb.toString()); } private void mergeDate(gtA gta) { if (this.chrono instanceof gsV) { checkDate(gsV.INSTANCE.resolveDate(this.fieldValues, gta)); } else if (this.fieldValues.containsKey(EnumC15534gtD.EPOCH_DAY)) { checkDate(C15520gsp.ofEpochDay(this.fieldValues.remove(EnumC15534gtD.EPOCH_DAY).longValue())); } } private void checkDate(C15520gsp c15520gsp) { if (c15520gsp != null) { addObject(c15520gsp); for (InterfaceC15537gtP interfaceC15537gtP : this.fieldValues.keySet()) { if ((interfaceC15537gtP instanceof EnumC15534gtD) && interfaceC15537gtP.isDateBased()) { try { long j = c15520gsp.getLong(interfaceC15537gtP); Long l = this.fieldValues.get(interfaceC15537gtP); if (j != l.longValue()) { StringBuilder sb = new StringBuilder("Conflict found: Field "); sb.append(interfaceC15537gtP); sb.append(" "); sb.append(j); sb.append(" differs from "); sb.append(interfaceC15537gtP); sb.append(" "); sb.append(l); sb.append(" derived from "); sb.append(c15520gsp); throw new DateTimeException(sb.toString()); } } catch (DateTimeException unused) { continue; } } } } } private void mergeTime(gtA gta) { if (this.fieldValues.containsKey(EnumC15534gtD.CLOCK_HOUR_OF_DAY)) { long longValue = this.fieldValues.remove(EnumC15534gtD.CLOCK_HOUR_OF_DAY).longValue(); if (gta != gtA.LENIENT && (gta != gtA.SMART || longValue != 0)) { EnumC15534gtD.CLOCK_HOUR_OF_DAY.checkValidValue(longValue); } EnumC15534gtD enumC15534gtD = EnumC15534gtD.HOUR_OF_DAY; if (longValue == 24) { longValue = 0; } addFieldValue(enumC15534gtD, longValue); } if (this.fieldValues.containsKey(EnumC15534gtD.CLOCK_HOUR_OF_AMPM)) { long longValue2 = this.fieldValues.remove(EnumC15534gtD.CLOCK_HOUR_OF_AMPM).longValue(); if (gta != gtA.LENIENT && (gta != gtA.SMART || longValue2 != 0)) { EnumC15534gtD.CLOCK_HOUR_OF_AMPM.checkValidValue(longValue2); } addFieldValue(EnumC15534gtD.HOUR_OF_AMPM, longValue2 != 12 ? longValue2 : 0L); } if (gta != gtA.LENIENT) { if (this.fieldValues.containsKey(EnumC15534gtD.AMPM_OF_DAY)) { EnumC15534gtD.AMPM_OF_DAY.checkValidValue(this.fieldValues.get(EnumC15534gtD.AMPM_OF_DAY).longValue()); } if (this.fieldValues.containsKey(EnumC15534gtD.HOUR_OF_AMPM)) { EnumC15534gtD.HOUR_OF_AMPM.checkValidValue(this.fieldValues.get(EnumC15534gtD.HOUR_OF_AMPM).longValue()); } } if (this.fieldValues.containsKey(EnumC15534gtD.AMPM_OF_DAY) && this.fieldValues.containsKey(EnumC15534gtD.HOUR_OF_AMPM)) { addFieldValue(EnumC15534gtD.HOUR_OF_DAY, (this.fieldValues.remove(EnumC15534gtD.AMPM_OF_DAY).longValue() * 12) + this.fieldValues.remove(EnumC15534gtD.HOUR_OF_AMPM).longValue()); } if (this.fieldValues.containsKey(EnumC15534gtD.NANO_OF_DAY)) { long longValue3 = this.fieldValues.remove(EnumC15534gtD.NANO_OF_DAY).longValue(); if (gta != gtA.LENIENT) { EnumC15534gtD.NANO_OF_DAY.checkValidValue(longValue3); } addFieldValue(EnumC15534gtD.SECOND_OF_DAY, longValue3 / 1000000000); addFieldValue(EnumC15534gtD.NANO_OF_SECOND, longValue3 % 1000000000); } if (this.fieldValues.containsKey(EnumC15534gtD.MICRO_OF_DAY)) { long longValue4 = this.fieldValues.remove(EnumC15534gtD.MICRO_OF_DAY).longValue(); if (gta != gtA.LENIENT) { EnumC15534gtD.MICRO_OF_DAY.checkValidValue(longValue4); } addFieldValue(EnumC15534gtD.SECOND_OF_DAY, longValue4 / 1000000); addFieldValue(EnumC15534gtD.MICRO_OF_SECOND, longValue4 % 1000000); } if (this.fieldValues.containsKey(EnumC15534gtD.MILLI_OF_DAY)) { long longValue5 = this.fieldValues.remove(EnumC15534gtD.MILLI_OF_DAY).longValue(); if (gta != gtA.LENIENT) { EnumC15534gtD.MILLI_OF_DAY.checkValidValue(longValue5); } addFieldValue(EnumC15534gtD.SECOND_OF_DAY, longValue5 / 1000); addFieldValue(EnumC15534gtD.MILLI_OF_SECOND, longValue5 % 1000); } if (this.fieldValues.containsKey(EnumC15534gtD.SECOND_OF_DAY)) { long longValue6 = this.fieldValues.remove(EnumC15534gtD.SECOND_OF_DAY).longValue(); if (gta != gtA.LENIENT) { EnumC15534gtD.SECOND_OF_DAY.checkValidValue(longValue6); } addFieldValue(EnumC15534gtD.HOUR_OF_DAY, longValue6 / 3600); addFieldValue(EnumC15534gtD.MINUTE_OF_HOUR, (longValue6 / 60) % 60); addFieldValue(EnumC15534gtD.SECOND_OF_MINUTE, longValue6 % 60); } if (this.fieldValues.containsKey(EnumC15534gtD.MINUTE_OF_DAY)) { long longValue7 = this.fieldValues.remove(EnumC15534gtD.MINUTE_OF_DAY).longValue(); if (gta != gtA.LENIENT) { EnumC15534gtD.MINUTE_OF_DAY.checkValidValue(longValue7); } addFieldValue(EnumC15534gtD.HOUR_OF_DAY, longValue7 / 60); addFieldValue(EnumC15534gtD.MINUTE_OF_HOUR, longValue7 % 60); } if (gta != gtA.LENIENT) { if (this.fieldValues.containsKey(EnumC15534gtD.MILLI_OF_SECOND)) { EnumC15534gtD.MILLI_OF_SECOND.checkValidValue(this.fieldValues.get(EnumC15534gtD.MILLI_OF_SECOND).longValue()); } if (this.fieldValues.containsKey(EnumC15534gtD.MICRO_OF_SECOND)) { EnumC15534gtD.MICRO_OF_SECOND.checkValidValue(this.fieldValues.get(EnumC15534gtD.MICRO_OF_SECOND).longValue()); } } if (this.fieldValues.containsKey(EnumC15534gtD.MILLI_OF_SECOND) && this.fieldValues.containsKey(EnumC15534gtD.MICRO_OF_SECOND)) { addFieldValue(EnumC15534gtD.MICRO_OF_SECOND, (this.fieldValues.remove(EnumC15534gtD.MILLI_OF_SECOND).longValue() * 1000) + (this.fieldValues.get(EnumC15534gtD.MICRO_OF_SECOND).longValue() % 1000)); } if (this.fieldValues.containsKey(EnumC15534gtD.MICRO_OF_SECOND) && this.fieldValues.containsKey(EnumC15534gtD.NANO_OF_SECOND)) { addFieldValue(EnumC15534gtD.MICRO_OF_SECOND, this.fieldValues.get(EnumC15534gtD.NANO_OF_SECOND).longValue() / 1000); this.fieldValues.remove(EnumC15534gtD.MICRO_OF_SECOND); } if (this.fieldValues.containsKey(EnumC15534gtD.MILLI_OF_SECOND) && this.fieldValues.containsKey(EnumC15534gtD.NANO_OF_SECOND)) { addFieldValue(EnumC15534gtD.MILLI_OF_SECOND, this.fieldValues.get(EnumC15534gtD.NANO_OF_SECOND).longValue() / 1000000); this.fieldValues.remove(EnumC15534gtD.MILLI_OF_SECOND); } if (this.fieldValues.containsKey(EnumC15534gtD.MICRO_OF_SECOND)) { addFieldValue(EnumC15534gtD.NANO_OF_SECOND, this.fieldValues.remove(EnumC15534gtD.MICRO_OF_SECOND).longValue() * 1000); } else if (this.fieldValues.containsKey(EnumC15534gtD.MILLI_OF_SECOND)) { addFieldValue(EnumC15534gtD.NANO_OF_SECOND, this.fieldValues.remove(EnumC15534gtD.MILLI_OF_SECOND).longValue() * 1000000); } } private void resolveTimeInferZeroes(gtA gta) { Long l = this.fieldValues.get(EnumC15534gtD.HOUR_OF_DAY); Long l2 = this.fieldValues.get(EnumC15534gtD.MINUTE_OF_HOUR); Long l3 = this.fieldValues.get(EnumC15534gtD.SECOND_OF_MINUTE); Long l4 = this.fieldValues.get(EnumC15534gtD.NANO_OF_SECOND); if (l == null) { return; } if (l2 != null || (l3 == null && l4 == null)) { if (l2 == null || l3 != null || l4 == null) { if (gta != gtA.LENIENT) { if (l != null) { if (gta == gtA.SMART && l.longValue() == 24 && ((l2 == null || l2.longValue() == 0) && ((l3 == null || l3.longValue() == 0) && (l4 == null || l4.longValue() == 0)))) { l = 0L; this.excessDays = C15500gsA.ofDays(1); } int checkValidIntValue = EnumC15534gtD.HOUR_OF_DAY.checkValidIntValue(l.longValue()); if (l2 != null) { int checkValidIntValue2 = EnumC15534gtD.MINUTE_OF_HOUR.checkValidIntValue(l2.longValue()); if (l3 != null) { int checkValidIntValue3 = EnumC15534gtD.SECOND_OF_MINUTE.checkValidIntValue(l3.longValue()); if (l4 != null) { addObject(C15521gsq.of(checkValidIntValue, checkValidIntValue2, checkValidIntValue3, EnumC15534gtD.NANO_OF_SECOND.checkValidIntValue(l4.longValue()))); } else { addObject(C15521gsq.of(checkValidIntValue, checkValidIntValue2, checkValidIntValue3)); } } else if (l4 == null) { addObject(C15521gsq.of(checkValidIntValue, checkValidIntValue2)); } } else if (l3 == null && l4 == null) { addObject(C15521gsq.of(checkValidIntValue, 0)); } } } else if (l != null) { long longValue = l.longValue(); if (l2 == null) { int safeToInt = gtG.safeToInt(gtG.floorDiv(longValue, 24L)); addObject(C15521gsq.of(gtG.floorMod(longValue, 24), 0)); this.excessDays = C15500gsA.ofDays(safeToInt); } else if (l3 != null) { if (l4 == null) { l4 = 0L; } long safeAdd = gtG.safeAdd(gtG.safeAdd(gtG.safeAdd(gtG.safeMultiply(longValue, 3600000000000L), gtG.safeMultiply(l2.longValue(), 60000000000L)), gtG.safeMultiply(l3.longValue(), 1000000000L)), l4.longValue()); int floorDiv = (int) gtG.floorDiv(safeAdd, 86400000000000L); addObject(C15521gsq.ofNanoOfDay(gtG.floorMod(safeAdd, 86400000000000L))); this.excessDays = C15500gsA.ofDays(floorDiv); } else { long safeAdd2 = gtG.safeAdd(gtG.safeMultiply(longValue, 3600L), gtG.safeMultiply(l2.longValue(), 60L)); int floorDiv2 = (int) gtG.floorDiv(safeAdd2, 86400L); addObject(C15521gsq.ofSecondOfDay(gtG.floorMod(safeAdd2, 86400L))); this.excessDays = C15500gsA.ofDays(floorDiv2); } } this.fieldValues.remove(EnumC15534gtD.HOUR_OF_DAY); this.fieldValues.remove(EnumC15534gtD.MINUTE_OF_HOUR); this.fieldValues.remove(EnumC15534gtD.SECOND_OF_MINUTE); this.fieldValues.remove(EnumC15534gtD.NANO_OF_SECOND); } } } private void mergeInstantFields() { if (this.fieldValues.containsKey(EnumC15534gtD.INSTANT_SECONDS)) { AbstractC15502gsH abstractC15502gsH = this.zone; if (abstractC15502gsH != null) { mergeInstantFields0(abstractC15502gsH); return; } Long l = this.fieldValues.get(EnumC15534gtD.OFFSET_SECONDS); if (l != null) { mergeInstantFields0(gsI.ofTotalSeconds(l.intValue())); } } } private void mergeInstantFields0(AbstractC15502gsH abstractC15502gsH) { gsS zonedDateTime = this.chrono.zonedDateTime(C15523gss.ofEpochSecond(this.fieldValues.remove(EnumC15534gtD.INSTANT_SECONDS).longValue()), abstractC15502gsH); if (this.date == null) { addObject(zonedDateTime.toLocalDate()); } else { resolveMakeChanges(EnumC15534gtD.INSTANT_SECONDS, zonedDateTime.toLocalDate()); } addFieldValue(EnumC15534gtD.SECOND_OF_DAY, zonedDateTime.toLocalTime().toSecondOfDay()); } private void crossCheck() { C15521gsq c15521gsq; if (this.fieldValues.size() > 0) { gsJ gsj = this.date; if (gsj != null && (c15521gsq = this.time) != null) { crossCheck(gsj.atTime(c15521gsq)); return; } if (gsj != null) { crossCheck(gsj); return; } gtK gtk = this.time; if (gtk != null) { crossCheck(gtk); } } } private void crossCheck(gtK gtk) { Iterator> it = this.fieldValues.entrySet().iterator(); while (it.hasNext()) { Map.Entry next = it.next(); InterfaceC15537gtP key = next.getKey(); long longValue = next.getValue().longValue(); if (gtk.isSupported(key)) { try { long j = gtk.getLong(key); if (j != longValue) { StringBuilder sb = new StringBuilder("Cross check failed: "); sb.append(key); sb.append(" "); sb.append(j); sb.append(" vs "); sb.append(key); sb.append(" "); sb.append(longValue); throw new DateTimeException(sb.toString()); } it.remove(); } catch (RuntimeException unused) { continue; } } } } private void resolveFractional() { if (this.time == null) { if (this.fieldValues.containsKey(EnumC15534gtD.INSTANT_SECONDS) || this.fieldValues.containsKey(EnumC15534gtD.SECOND_OF_DAY) || this.fieldValues.containsKey(EnumC15534gtD.SECOND_OF_MINUTE)) { if (this.fieldValues.containsKey(EnumC15534gtD.NANO_OF_SECOND)) { long longValue = this.fieldValues.get(EnumC15534gtD.NANO_OF_SECOND).longValue(); this.fieldValues.put(EnumC15534gtD.MICRO_OF_SECOND, Long.valueOf(longValue / 1000)); this.fieldValues.put(EnumC15534gtD.MILLI_OF_SECOND, Long.valueOf(longValue / 1000000)); } else { this.fieldValues.put(EnumC15534gtD.NANO_OF_SECOND, 0L); this.fieldValues.put(EnumC15534gtD.MICRO_OF_SECOND, 0L); this.fieldValues.put(EnumC15534gtD.MILLI_OF_SECOND, 0L); } } } } private void resolveInstant() { if (this.date == null || this.time == null) { return; } Long l = this.fieldValues.get(EnumC15534gtD.OFFSET_SECONDS); if (l != null) { this.fieldValues.put(EnumC15534gtD.INSTANT_SECONDS, Long.valueOf(this.date.atTime(this.time).atZone2(gsI.ofTotalSeconds(l.intValue())).getLong(EnumC15534gtD.INSTANT_SECONDS))); } else if (this.zone != null) { this.fieldValues.put(EnumC15534gtD.INSTANT_SECONDS, Long.valueOf(this.date.atTime(this.time).atZone2(this.zone).getLong(EnumC15534gtD.INSTANT_SECONDS))); } } public final R build(gtQ gtq) { return gtq.queryFrom(this); } @Override // o.gtK public final boolean isSupported(InterfaceC15537gtP interfaceC15537gtP) { gsJ gsj; C15521gsq c15521gsq; if (interfaceC15537gtP == null) { return false; } return this.fieldValues.containsKey(interfaceC15537gtP) || ((gsj = this.date) != null && gsj.isSupported(interfaceC15537gtP)) || ((c15521gsq = this.time) != null && c15521gsq.isSupported(interfaceC15537gtP)); } @Override // o.gtK public final long getLong(InterfaceC15537gtP interfaceC15537gtP) { gtG.requireNonNull(interfaceC15537gtP, "field"); Long fieldValue0 = getFieldValue0(interfaceC15537gtP); if (fieldValue0 == null) { gsJ gsj = this.date; if (gsj != null && gsj.isSupported(interfaceC15537gtP)) { return this.date.getLong(interfaceC15537gtP); } C15521gsq c15521gsq = this.time; if (c15521gsq != null && c15521gsq.isSupported(interfaceC15537gtP)) { return this.time.getLong(interfaceC15537gtP); } throw new DateTimeException("Field not found: ".concat(String.valueOf(interfaceC15537gtP))); } return fieldValue0.longValue(); } @Override // o.gtE, o.gtK public final R query(gtQ gtq) { if (gtq == gtM.zoneId()) { return (R) this.zone; } if (gtq == gtM.chronology()) { return (R) this.chrono; } if (gtq == gtM.localDate()) { gsJ gsj = this.date; if (gsj != null) { return (R) C15520gsp.from((gtK) gsj); } return null; } if (gtq == gtM.localTime()) { return (R) this.time; } if (gtq == gtM.zone() || gtq == gtM.offset()) { return gtq.queryFrom(this); } if (gtq == gtM.precision()) { return null; } return gtq.queryFrom(this); } public final String toString() { StringBuilder sb = new StringBuilder(128); sb.append("DateTimeBuilder["); if (this.fieldValues.size() > 0) { sb.append("fields="); sb.append(this.fieldValues); } sb.append(", "); sb.append(this.chrono); sb.append(", "); sb.append(this.zone); sb.append(", "); sb.append(this.date); sb.append(", "); sb.append(this.time); sb.append(']'); return sb.toString(); } final void addObject(gsJ gsj) { this.date = gsj; } final void addObject(C15521gsq c15521gsq) { this.time = c15521gsq; } }