package o; import java.io.Serializable; import java.util.Arrays; import java.util.Collections; import java.util.List; import org.threeten.bp.DateTimeException; import org.threeten.bp.temporal.UnsupportedTemporalTypeException; /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.gsU, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public final class C15503gsU extends gsT implements Serializable { private static final long serialVersionUID = 275618735781L; private final gsR chronology; private final int days; private final int months; private final int years; public C15503gsU(gsR gsr, int i, int i2, int i3) { this.chronology = gsr; this.years = i; this.months = i2; this.days = i3; } @Override // o.gsT, o.gtN public final long get(InterfaceC15539gtV interfaceC15539gtV) { int i; if (interfaceC15539gtV == gtH.YEARS) { i = this.years; } else if (interfaceC15539gtV == gtH.MONTHS) { i = this.months; } else { if (interfaceC15539gtV != gtH.DAYS) { throw new UnsupportedTemporalTypeException("Unsupported unit: ".concat(String.valueOf(interfaceC15539gtV))); } i = this.days; } return i; } @Override // o.gsT, o.gtN public final List getUnits() { return Collections.unmodifiableList(Arrays.asList(gtH.YEARS, gtH.MONTHS, gtH.DAYS)); } @Override // o.gsT public final gsT plus(gtN gtn) { if (gtn instanceof C15503gsU) { C15503gsU c15503gsU = (C15503gsU) gtn; if (c15503gsU.getChronology().equals(getChronology())) { return new C15503gsU(this.chronology, gtG.safeAdd(this.years, c15503gsU.years), gtG.safeAdd(this.months, c15503gsU.months), gtG.safeAdd(this.days, c15503gsU.days)); } } throw new DateTimeException("Unable to add amount: ".concat(String.valueOf(gtn))); } @Override // o.gsT public final gsT minus(gtN gtn) { if (gtn instanceof C15503gsU) { C15503gsU c15503gsU = (C15503gsU) gtn; if (c15503gsU.getChronology().equals(getChronology())) { return new C15503gsU(this.chronology, gtG.safeSubtract(this.years, c15503gsU.years), gtG.safeSubtract(this.months, c15503gsU.months), gtG.safeSubtract(this.days, c15503gsU.days)); } } throw new DateTimeException("Unable to subtract amount: ".concat(String.valueOf(gtn))); } @Override // o.gsT public final gsT multipliedBy(int i) { return new C15503gsU(this.chronology, gtG.safeMultiply(this.years, i), gtG.safeMultiply(this.months, i), gtG.safeMultiply(this.days, i)); } @Override // o.gsT public final gsT normalized() { if (!this.chronology.range(EnumC15534gtD.MONTH_OF_YEAR).isFixed()) { return this; } long maximum = (this.chronology.range(EnumC15534gtD.MONTH_OF_YEAR).getMaximum() - this.chronology.range(EnumC15534gtD.MONTH_OF_YEAR).getMinimum()) + 1; long j = (this.years * maximum) + this.months; return new C15503gsU(this.chronology, gtG.safeToInt(j / maximum), gtG.safeToInt(j % maximum), this.days); } @Override // o.gsT, o.gtN public final InterfaceC15536gtL addTo(InterfaceC15536gtL interfaceC15536gtL) { gtG.requireNonNull(interfaceC15536gtL, "temporal"); gsR gsr = (gsR) interfaceC15536gtL.query(gtM.chronology()); if (gsr != null && !this.chronology.equals(gsr)) { StringBuilder sb = new StringBuilder("Invalid chronology, required: "); sb.append(this.chronology.getId()); sb.append(", but was: "); sb.append(gsr.getId()); throw new DateTimeException(sb.toString()); } int i = this.years; if (i != 0) { interfaceC15536gtL = interfaceC15536gtL.plus(i, gtH.YEARS); } int i2 = this.months; if (i2 != 0) { interfaceC15536gtL = interfaceC15536gtL.plus(i2, gtH.MONTHS); } int i3 = this.days; return i3 != 0 ? interfaceC15536gtL.plus(i3, gtH.DAYS) : interfaceC15536gtL; } @Override // o.gsT, o.gtN public final InterfaceC15536gtL subtractFrom(InterfaceC15536gtL interfaceC15536gtL) { gtG.requireNonNull(interfaceC15536gtL, "temporal"); gsR gsr = (gsR) interfaceC15536gtL.query(gtM.chronology()); if (gsr != null && !this.chronology.equals(gsr)) { StringBuilder sb = new StringBuilder("Invalid chronology, required: "); sb.append(this.chronology.getId()); sb.append(", but was: "); sb.append(gsr.getId()); throw new DateTimeException(sb.toString()); } int i = this.years; if (i != 0) { interfaceC15536gtL = interfaceC15536gtL.minus(i, gtH.YEARS); } int i2 = this.months; if (i2 != 0) { interfaceC15536gtL = interfaceC15536gtL.minus(i2, gtH.MONTHS); } int i3 = this.days; return i3 != 0 ? interfaceC15536gtL.minus(i3, gtH.DAYS) : interfaceC15536gtL; } @Override // o.gsT public final boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof C15503gsU)) { return false; } C15503gsU c15503gsU = (C15503gsU) obj; return this.years == c15503gsU.years && this.months == c15503gsU.months && this.days == c15503gsU.days && this.chronology.equals(c15503gsU.chronology); } @Override // o.gsT public final int hashCode() { return this.chronology.hashCode() + Integer.rotateLeft(this.years, 16) + Integer.rotateLeft(this.months, 8) + this.days; } @Override // o.gsT public final String toString() { if (isZero()) { StringBuilder sb = new StringBuilder(); sb.append(this.chronology); sb.append(" P0D"); return sb.toString(); } StringBuilder sb2 = new StringBuilder(); sb2.append(this.chronology); sb2.append(" P"); int i = this.years; if (i != 0) { sb2.append(i); sb2.append('Y'); } int i2 = this.months; if (i2 != 0) { sb2.append(i2); sb2.append('M'); } int i3 = this.days; if (i3 != 0) { sb2.append(i3); sb2.append('D'); } return sb2.toString(); } @Override // o.gsT public final gsR getChronology() { return this.chronology; } }