package o; import com.huawei.hms.android.HwBuildEx; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.io.InvalidObjectException; import java.io.ObjectStreamException; import java.io.Serializable; import net.sf.scuba.smartcards.ISO7816; import org.threeten.bp.DateTimeException; import org.threeten.bp.temporal.UnsupportedTemporalTypeException; /* loaded from: classes6.dex */ public final class gsG extends gtE implements InterfaceC15536gtL, gtJ, Comparable, Serializable { public static final gtQ FROM = new gtQ() { // from class: o.gsG.2 @Override // o.gtQ public final gsG queryFrom(gtK gtk) { return gsG.from(gtk); } }; private static final C15554gto PARSER = new C15553gtn().appendValue(EnumC15534gtD.YEAR, 4, 10, EnumC15564gty.EXCEEDS_PAD).appendLiteral('-').appendValue(EnumC15534gtD.MONTH_OF_YEAR, 2).toFormatter(); private static final long serialVersionUID = 4183400860270640070L; private final int month; private final int year; public static gsG now() { return now(AbstractC15514gsj.systemDefaultZone()); } public static gsG now(AbstractC15502gsH abstractC15502gsH) { return now(AbstractC15514gsj.system(abstractC15502gsH)); } public static gsG now(AbstractC15514gsj abstractC15514gsj) { C15520gsp now = C15520gsp.now(abstractC15514gsj); return of(now.getYear(), now.getMonth()); } public static gsG of(int i, EnumC15528gsx enumC15528gsx) { gtG.requireNonNull(enumC15528gsx, "month"); return of(i, enumC15528gsx.getValue()); } public static gsG of(int i, int i2) { EnumC15534gtD.YEAR.checkValidValue(i); EnumC15534gtD.MONTH_OF_YEAR.checkValidValue(i2); return new gsG(i, i2); } public static gsG from(gtK gtk) { if (gtk instanceof gsG) { return (gsG) gtk; } try { if (!gsV.INSTANCE.equals(gsR.from(gtk))) { gtk = C15520gsp.from(gtk); } return of(gtk.get(EnumC15534gtD.YEAR), gtk.get(EnumC15534gtD.MONTH_OF_YEAR)); } catch (DateTimeException unused) { StringBuilder sb = new StringBuilder("Unable to obtain YearMonth from TemporalAccessor: "); sb.append(gtk); sb.append(", type "); sb.append(gtk.getClass().getName()); throw new DateTimeException(sb.toString()); } } public static gsG parse(CharSequence charSequence) { return parse(charSequence, PARSER); } public static gsG parse(CharSequence charSequence, C15554gto c15554gto) { gtG.requireNonNull(c15554gto, "formatter"); return (gsG) c15554gto.parse(charSequence, FROM); } private gsG(int i, int i2) { this.year = i; this.month = i2; } private gsG with(int i, int i2) { return (this.year == i && this.month == i2) ? this : new gsG(i, i2); } @Override // o.gtK public final boolean isSupported(InterfaceC15537gtP interfaceC15537gtP) { return interfaceC15537gtP instanceof EnumC15534gtD ? interfaceC15537gtP == EnumC15534gtD.YEAR || interfaceC15537gtP == EnumC15534gtD.MONTH_OF_YEAR || interfaceC15537gtP == EnumC15534gtD.PROLEPTIC_MONTH || interfaceC15537gtP == EnumC15534gtD.YEAR_OF_ERA || interfaceC15537gtP == EnumC15534gtD.ERA : interfaceC15537gtP != null && interfaceC15537gtP.isSupportedBy(this); } @Override // o.InterfaceC15536gtL public final boolean isSupported(InterfaceC15539gtV interfaceC15539gtV) { return interfaceC15539gtV instanceof gtH ? interfaceC15539gtV == gtH.MONTHS || interfaceC15539gtV == gtH.YEARS || interfaceC15539gtV == gtH.DECADES || interfaceC15539gtV == gtH.CENTURIES || interfaceC15539gtV == gtH.MILLENNIA || interfaceC15539gtV == gtH.ERAS : interfaceC15539gtV != null && interfaceC15539gtV.isSupportedBy(this); } @Override // o.gtE, o.gtK public final gtT range(InterfaceC15537gtP interfaceC15537gtP) { if (interfaceC15537gtP == EnumC15534gtD.YEAR_OF_ERA) { return gtT.of(1L, getYear() <= 0 ? 1000000000L : 999999999L); } return super.range(interfaceC15537gtP); } @Override // o.gtE, o.gtK public final int get(InterfaceC15537gtP interfaceC15537gtP) { return range(interfaceC15537gtP).checkValidIntValue(getLong(interfaceC15537gtP), interfaceC15537gtP); } @Override // o.gtK public final long getLong(InterfaceC15537gtP interfaceC15537gtP) { int i; if (interfaceC15537gtP instanceof EnumC15534gtD) { int i2 = AnonymousClass4.$SwitchMap$org$threeten$bp$temporal$ChronoField[((EnumC15534gtD) interfaceC15537gtP).ordinal()]; if (i2 == 1) { i = this.month; } else { if (i2 == 2) { return getProlepticMonth(); } if (i2 == 3) { int i3 = this.year; if (i3 <= 0) { i3 = 1 - i3; } return i3; } if (i2 != 4) { if (i2 == 5) { return this.year <= 0 ? 0 : 1; } throw new UnsupportedTemporalTypeException("Unsupported field: ".concat(String.valueOf(interfaceC15537gtP))); } i = this.year; } return i; } return interfaceC15537gtP.getFrom(this); } public final EnumC15528gsx getMonth() { return EnumC15528gsx.of(this.month); } public final boolean isLeapYear() { return gsV.INSTANCE.isLeapYear(this.year); } public final boolean isValidDay(int i) { return i > 0 && i <= lengthOfMonth(); } public final int lengthOfMonth() { return getMonth().length(isLeapYear()); } public final int lengthOfYear() { return isLeapYear() ? 366 : 365; } @Override // o.InterfaceC15536gtL public final gsG with(gtJ gtj) { return (gsG) gtj.adjustInto(this); } @Override // o.InterfaceC15536gtL public final gsG with(InterfaceC15537gtP interfaceC15537gtP, long j) { if (interfaceC15537gtP instanceof EnumC15534gtD) { EnumC15534gtD enumC15534gtD = (EnumC15534gtD) interfaceC15537gtP; enumC15534gtD.checkValidValue(j); int i = AnonymousClass4.$SwitchMap$org$threeten$bp$temporal$ChronoField[enumC15534gtD.ordinal()]; if (i == 1) { return withMonth((int) j); } if (i == 2) { return plusMonths(j - getLong(EnumC15534gtD.PROLEPTIC_MONTH)); } if (i == 3) { if (this.year <= 0) { j = 1 - j; } return withYear((int) j); } if (i == 4) { return withYear((int) j); } if (i == 5) { return getLong(EnumC15534gtD.ERA) == j ? this : withYear(1 - this.year); } throw new UnsupportedTemporalTypeException("Unsupported field: ".concat(String.valueOf(interfaceC15537gtP))); } return (gsG) interfaceC15537gtP.adjustInto(this, j); } public final gsG withYear(int i) { EnumC15534gtD.YEAR.checkValidValue(i); return with(i, this.month); } public final gsG withMonth(int i) { EnumC15534gtD.MONTH_OF_YEAR.checkValidValue(i); return with(this.year, i); } @Override // o.InterfaceC15536gtL public final gsG plus(gtN gtn) { return (gsG) gtn.addTo(this); } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.gsG$4, reason: invalid class name */ /* loaded from: classes6.dex */ public static /* synthetic */ class AnonymousClass4 { static final int[] $SwitchMap$org$threeten$bp$temporal$ChronoField; static final int[] $SwitchMap$org$threeten$bp$temporal$ChronoUnit; static { int[] iArr = new int[gtH.values().length]; $SwitchMap$org$threeten$bp$temporal$ChronoUnit = iArr; try { iArr[gtH.MONTHS.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { $SwitchMap$org$threeten$bp$temporal$ChronoUnit[gtH.YEARS.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { $SwitchMap$org$threeten$bp$temporal$ChronoUnit[gtH.DECADES.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } try { $SwitchMap$org$threeten$bp$temporal$ChronoUnit[gtH.CENTURIES.ordinal()] = 4; } catch (NoSuchFieldError unused4) { } try { $SwitchMap$org$threeten$bp$temporal$ChronoUnit[gtH.MILLENNIA.ordinal()] = 5; } catch (NoSuchFieldError unused5) { } try { $SwitchMap$org$threeten$bp$temporal$ChronoUnit[gtH.ERAS.ordinal()] = 6; } catch (NoSuchFieldError unused6) { } int[] iArr2 = new int[EnumC15534gtD.values().length]; $SwitchMap$org$threeten$bp$temporal$ChronoField = iArr2; try { iArr2[EnumC15534gtD.MONTH_OF_YEAR.ordinal()] = 1; } catch (NoSuchFieldError unused7) { } try { $SwitchMap$org$threeten$bp$temporal$ChronoField[EnumC15534gtD.PROLEPTIC_MONTH.ordinal()] = 2; } catch (NoSuchFieldError unused8) { } try { $SwitchMap$org$threeten$bp$temporal$ChronoField[EnumC15534gtD.YEAR_OF_ERA.ordinal()] = 3; } catch (NoSuchFieldError unused9) { } try { $SwitchMap$org$threeten$bp$temporal$ChronoField[EnumC15534gtD.YEAR.ordinal()] = 4; } catch (NoSuchFieldError unused10) { } try { $SwitchMap$org$threeten$bp$temporal$ChronoField[EnumC15534gtD.ERA.ordinal()] = 5; } catch (NoSuchFieldError unused11) { } } } @Override // o.InterfaceC15536gtL public final gsG plus(long j, InterfaceC15539gtV interfaceC15539gtV) { if (interfaceC15539gtV instanceof gtH) { switch (AnonymousClass4.$SwitchMap$org$threeten$bp$temporal$ChronoUnit[((gtH) interfaceC15539gtV).ordinal()]) { case 1: return plusMonths(j); case 2: return plusYears(j); case 3: return plusYears(gtG.safeMultiply(j, 10)); case 4: return plusYears(gtG.safeMultiply(j, 100)); case 5: return plusYears(gtG.safeMultiply(j, 1000)); case 6: return with((InterfaceC15537gtP) EnumC15534gtD.ERA, gtG.safeAdd(getLong(EnumC15534gtD.ERA), j)); default: throw new UnsupportedTemporalTypeException("Unsupported unit: ".concat(String.valueOf(interfaceC15539gtV))); } } return (gsG) interfaceC15539gtV.addTo(this, j); } public final gsG plusYears(long j) { return j == 0 ? this : with(EnumC15534gtD.YEAR.checkValidIntValue(this.year + j), this.month); } public final gsG plusMonths(long j) { if (j == 0) { return this; } long j2 = (this.year * 12) + (this.month - 1) + j; return with(EnumC15534gtD.YEAR.checkValidIntValue(gtG.floorDiv(j2, 12L)), gtG.floorMod(j2, 12) + 1); } @Override // o.InterfaceC15536gtL public final gsG minus(gtN gtn) { return (gsG) gtn.subtractFrom(this); } @Override // o.InterfaceC15536gtL public final gsG minus(long j, InterfaceC15539gtV interfaceC15539gtV) { return j == Long.MIN_VALUE ? plus(Long.MAX_VALUE, interfaceC15539gtV).plus(1L, interfaceC15539gtV) : plus(-j, interfaceC15539gtV); } public final gsG minusYears(long j) { return j == Long.MIN_VALUE ? plusYears(Long.MAX_VALUE).plusYears(1L) : plusYears(-j); } public final gsG minusMonths(long j) { return j == Long.MIN_VALUE ? plusMonths(Long.MAX_VALUE).plusMonths(1L) : plusMonths(-j); } @Override // o.gtE, o.gtK public final R query(gtQ gtq) { if (gtq == gtM.chronology()) { return (R) gsV.INSTANCE; } if (gtq == gtM.precision()) { return (R) gtH.MONTHS; } if (gtq == gtM.localDate() || gtq == gtM.localTime() || gtq == gtM.zone() || gtq == gtM.zoneId() || gtq == gtM.offset()) { return null; } return (R) super.query(gtq); } @Override // o.gtJ public final InterfaceC15536gtL adjustInto(InterfaceC15536gtL interfaceC15536gtL) { if (!gsR.from(interfaceC15536gtL).equals(gsV.INSTANCE)) { throw new DateTimeException("Adjustment only supported on ISO date-time"); } return interfaceC15536gtL.with(EnumC15534gtD.PROLEPTIC_MONTH, getProlepticMonth()); } @Override // o.InterfaceC15536gtL public final long until(InterfaceC15536gtL interfaceC15536gtL, InterfaceC15539gtV interfaceC15539gtV) { gsG from = from(interfaceC15536gtL); if (interfaceC15539gtV instanceof gtH) { long prolepticMonth = from.getProlepticMonth() - getProlepticMonth(); switch (AnonymousClass4.$SwitchMap$org$threeten$bp$temporal$ChronoUnit[((gtH) interfaceC15539gtV).ordinal()]) { case 1: return prolepticMonth; case 2: return prolepticMonth / 12; case 3: return prolepticMonth / 120; case 4: return prolepticMonth / 1200; case 5: return prolepticMonth / 12000; case 6: return from.getLong(EnumC15534gtD.ERA) - getLong(EnumC15534gtD.ERA); default: throw new UnsupportedTemporalTypeException("Unsupported unit: ".concat(String.valueOf(interfaceC15539gtV))); } } return interfaceC15539gtV.between(this, from); } public final C15520gsp atDay(int i) { return C15520gsp.of(this.year, this.month, i); } public final C15520gsp atEndOfMonth() { return C15520gsp.of(this.year, this.month, lengthOfMonth()); } @Override // java.lang.Comparable public final int compareTo(gsG gsg) { int i = this.year - gsg.year; return i == 0 ? this.month - gsg.month : i; } public final boolean isAfter(gsG gsg) { return compareTo(gsg) > 0; } public final boolean isBefore(gsG gsg) { return compareTo(gsg) < 0; } public final boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof gsG)) { return false; } gsG gsg = (gsG) obj; return this.year == gsg.year && this.month == gsg.month; } public final String toString() { int abs = Math.abs(this.year); StringBuilder sb = new StringBuilder(9); if (abs < 1000) { int i = this.year; if (i < 0) { sb.append(i - 10000); sb.deleteCharAt(1); } else { sb.append(i + HwBuildEx.VersionCodes.CUR_DEVELOPMENT); sb.deleteCharAt(0); } } else { sb.append(this.year); } sb.append(this.month < 10 ? "-0" : "-"); sb.append(this.month); return sb.toString(); } public final String format(C15554gto c15554gto) { gtG.requireNonNull(c15554gto, "formatter"); return c15554gto.format(this); } private Object writeReplace() { return new C15501gsD(ISO7816.INS_REHABILITATE_CHV, this); } private Object readResolve() throws ObjectStreamException { throw new InvalidObjectException("Deserialization via serialization delegate"); } /* JADX INFO: Access modifiers changed from: package-private */ public final void writeExternal(DataOutput dataOutput) throws IOException { dataOutput.writeInt(this.year); dataOutput.writeByte(this.month); } /* JADX INFO: Access modifiers changed from: package-private */ public static gsG readExternal(DataInput dataInput) throws IOException { return of(dataInput.readInt(), dataInput.readByte()); } public final int hashCode() { return this.year ^ (this.month << 27); } public final int getYear() { return this.year; } public final int getMonthValue() { return this.month; } private long getProlepticMonth() { return (this.year * 12) + (this.month - 1); } }