313 lines
11 KiB
Java
313 lines
11 KiB
Java
package o;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import org.threeten.bp.DateTimeException;
|
|
import org.threeten.bp.format.DateTimeParseException;
|
|
import org.threeten.bp.temporal.UnsupportedTemporalTypeException;
|
|
|
|
/* renamed from: o.gsA, reason: case insensitive filesystem */
|
|
/* loaded from: classes6.dex */
|
|
public final class C15500gsA extends gsT implements Serializable {
|
|
private static final long serialVersionUID = -8290556941213247973L;
|
|
private final int days;
|
|
private final int months;
|
|
private final int years;
|
|
public static final C15500gsA ZERO = new C15500gsA(0, 0, 0);
|
|
private static final Pattern PATTERN = Pattern.compile("([-+]?)P(?:([-+]?[0-9]+)Y)?(?:([-+]?[0-9]+)M)?(?:([-+]?[0-9]+)W)?(?:([-+]?[0-9]+)D)?", 2);
|
|
|
|
public static C15500gsA ofYears(int i) {
|
|
return create(i, 0, 0);
|
|
}
|
|
|
|
public static C15500gsA ofMonths(int i) {
|
|
return create(0, i, 0);
|
|
}
|
|
|
|
public static C15500gsA ofWeeks(int i) {
|
|
return create(0, 0, gtG.safeMultiply(i, 7));
|
|
}
|
|
|
|
public static C15500gsA ofDays(int i) {
|
|
return create(0, 0, i);
|
|
}
|
|
|
|
public static C15500gsA of(int i, int i2, int i3) {
|
|
return create(i, i2, i3);
|
|
}
|
|
|
|
public static C15500gsA from(gtN gtn) {
|
|
if (gtn instanceof C15500gsA) {
|
|
return (C15500gsA) gtn;
|
|
}
|
|
if ((gtn instanceof gsT) && !gsV.INSTANCE.equals(((gsT) gtn).getChronology())) {
|
|
throw new DateTimeException("Period requires ISO chronology: ".concat(String.valueOf(gtn)));
|
|
}
|
|
gtG.requireNonNull(gtn, "amount");
|
|
int i = 0;
|
|
int i2 = 0;
|
|
int i3 = 0;
|
|
for (InterfaceC15539gtV interfaceC15539gtV : gtn.getUnits()) {
|
|
long j = gtn.get(interfaceC15539gtV);
|
|
if (interfaceC15539gtV == gtH.YEARS) {
|
|
i = gtG.safeToInt(j);
|
|
} else if (interfaceC15539gtV == gtH.MONTHS) {
|
|
i2 = gtG.safeToInt(j);
|
|
} else if (interfaceC15539gtV == gtH.DAYS) {
|
|
i3 = gtG.safeToInt(j);
|
|
} else {
|
|
throw new DateTimeException("Unit must be Years, Months or Days, but was ".concat(String.valueOf(interfaceC15539gtV)));
|
|
}
|
|
}
|
|
return create(i, i2, i3);
|
|
}
|
|
|
|
public static C15500gsA between(C15520gsp c15520gsp, C15520gsp c15520gsp2) {
|
|
return c15520gsp.until((gsJ) c15520gsp2);
|
|
}
|
|
|
|
public static C15500gsA parse(CharSequence charSequence) {
|
|
gtG.requireNonNull(charSequence, "text");
|
|
Matcher matcher = PATTERN.matcher(charSequence);
|
|
if (matcher.matches()) {
|
|
int i = "-".equals(matcher.group(1)) ? -1 : 1;
|
|
String group = matcher.group(2);
|
|
String group2 = matcher.group(3);
|
|
String group3 = matcher.group(4);
|
|
String group4 = matcher.group(5);
|
|
if (group != null || group2 != null || group3 != null || group4 != null) {
|
|
try {
|
|
return create(parseNumber(charSequence, group, i), parseNumber(charSequence, group2, i), gtG.safeAdd(parseNumber(charSequence, group4, i), gtG.safeMultiply(parseNumber(charSequence, group3, i), 7)));
|
|
} catch (NumberFormatException e) {
|
|
throw ((DateTimeParseException) new DateTimeParseException("Text cannot be parsed to a Period", charSequence, 0).initCause(e));
|
|
}
|
|
}
|
|
}
|
|
throw new DateTimeParseException("Text cannot be parsed to a Period", charSequence, 0);
|
|
}
|
|
|
|
private static int parseNumber(CharSequence charSequence, String str, int i) {
|
|
if (str == null) {
|
|
return 0;
|
|
}
|
|
try {
|
|
return gtG.safeMultiply(Integer.parseInt(str), i);
|
|
} catch (ArithmeticException e) {
|
|
throw ((DateTimeParseException) new DateTimeParseException("Text cannot be parsed to a Period", charSequence, 0).initCause(e));
|
|
}
|
|
}
|
|
|
|
private static C15500gsA create(int i, int i2, int i3) {
|
|
return ((i | i2) | i3) == 0 ? ZERO : new C15500gsA(i, i2, i3);
|
|
}
|
|
|
|
private C15500gsA(int i, int i2, int i3) {
|
|
this.years = i;
|
|
this.months = i2;
|
|
this.days = i3;
|
|
}
|
|
|
|
@Override // o.gsT, o.gtN
|
|
public final List<InterfaceC15539gtV> getUnits() {
|
|
return Collections.unmodifiableList(Arrays.asList(gtH.YEARS, gtH.MONTHS, gtH.DAYS));
|
|
}
|
|
|
|
@Override // o.gsT
|
|
public final gsR getChronology() {
|
|
return gsV.INSTANCE;
|
|
}
|
|
|
|
@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;
|
|
}
|
|
|
|
public final C15500gsA withYears(int i) {
|
|
return i == this.years ? this : create(i, this.months, this.days);
|
|
}
|
|
|
|
public final C15500gsA withMonths(int i) {
|
|
return i == this.months ? this : create(this.years, i, this.days);
|
|
}
|
|
|
|
public final C15500gsA withDays(int i) {
|
|
return i == this.days ? this : create(this.years, this.months, i);
|
|
}
|
|
|
|
@Override // o.gsT
|
|
public final C15500gsA plus(gtN gtn) {
|
|
C15500gsA from = from(gtn);
|
|
return create(gtG.safeAdd(this.years, from.years), gtG.safeAdd(this.months, from.months), gtG.safeAdd(this.days, from.days));
|
|
}
|
|
|
|
public final C15500gsA plusYears(long j) {
|
|
return j == 0 ? this : create(gtG.safeToInt(gtG.safeAdd(this.years, j)), this.months, this.days);
|
|
}
|
|
|
|
public final C15500gsA plusMonths(long j) {
|
|
return j == 0 ? this : create(this.years, gtG.safeToInt(gtG.safeAdd(this.months, j)), this.days);
|
|
}
|
|
|
|
public final C15500gsA plusDays(long j) {
|
|
return j == 0 ? this : create(this.years, this.months, gtG.safeToInt(gtG.safeAdd(this.days, j)));
|
|
}
|
|
|
|
@Override // o.gsT
|
|
public final C15500gsA minus(gtN gtn) {
|
|
C15500gsA from = from(gtn);
|
|
return create(gtG.safeSubtract(this.years, from.years), gtG.safeSubtract(this.months, from.months), gtG.safeSubtract(this.days, from.days));
|
|
}
|
|
|
|
public final C15500gsA minusYears(long j) {
|
|
return j == Long.MIN_VALUE ? plusYears(Long.MAX_VALUE).plusYears(1L) : plusYears(-j);
|
|
}
|
|
|
|
public final C15500gsA minusMonths(long j) {
|
|
return j == Long.MIN_VALUE ? plusMonths(Long.MAX_VALUE).plusMonths(1L) : plusMonths(-j);
|
|
}
|
|
|
|
public final C15500gsA minusDays(long j) {
|
|
return j == Long.MIN_VALUE ? plusDays(Long.MAX_VALUE).plusDays(1L) : plusDays(-j);
|
|
}
|
|
|
|
@Override // o.gsT
|
|
public final C15500gsA multipliedBy(int i) {
|
|
return (this == ZERO || i == 1) ? this : create(gtG.safeMultiply(this.years, i), gtG.safeMultiply(this.months, i), gtG.safeMultiply(this.days, i));
|
|
}
|
|
|
|
@Override // o.gsT
|
|
public final C15500gsA negated() {
|
|
return multipliedBy(-1);
|
|
}
|
|
|
|
@Override // o.gsT
|
|
public final C15500gsA normalized() {
|
|
long totalMonths = toTotalMonths();
|
|
long j = totalMonths / 12;
|
|
int i = (int) (totalMonths % 12);
|
|
return (j == ((long) this.years) && i == this.months) ? this : create(gtG.safeToInt(j), i, this.days);
|
|
}
|
|
|
|
@Override // o.gsT, o.gtN
|
|
public final InterfaceC15536gtL addTo(InterfaceC15536gtL interfaceC15536gtL) {
|
|
gtG.requireNonNull(interfaceC15536gtL, "temporal");
|
|
int i = this.years;
|
|
if (i == 0) {
|
|
int i2 = this.months;
|
|
if (i2 != 0) {
|
|
interfaceC15536gtL = interfaceC15536gtL.plus(i2, gtH.MONTHS);
|
|
}
|
|
} else if (this.months != 0) {
|
|
interfaceC15536gtL = interfaceC15536gtL.plus(toTotalMonths(), gtH.MONTHS);
|
|
} else {
|
|
interfaceC15536gtL = interfaceC15536gtL.plus(i, gtH.YEARS);
|
|
}
|
|
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");
|
|
int i = this.years;
|
|
if (i == 0) {
|
|
int i2 = this.months;
|
|
if (i2 != 0) {
|
|
interfaceC15536gtL = interfaceC15536gtL.minus(i2, gtH.MONTHS);
|
|
}
|
|
} else if (this.months != 0) {
|
|
interfaceC15536gtL = interfaceC15536gtL.minus(toTotalMonths(), gtH.MONTHS);
|
|
} else {
|
|
interfaceC15536gtL = interfaceC15536gtL.minus(i, gtH.YEARS);
|
|
}
|
|
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 C15500gsA)) {
|
|
return false;
|
|
}
|
|
C15500gsA c15500gsA = (C15500gsA) obj;
|
|
return this.years == c15500gsA.years && this.months == c15500gsA.months && this.days == c15500gsA.days;
|
|
}
|
|
|
|
@Override // o.gsT
|
|
public final int hashCode() {
|
|
return this.years + Integer.rotateLeft(this.months, 8) + Integer.rotateLeft(this.days, 16);
|
|
}
|
|
|
|
@Override // o.gsT
|
|
public final String toString() {
|
|
if (this == ZERO) {
|
|
return "P0D";
|
|
}
|
|
StringBuilder sb = new StringBuilder("P");
|
|
int i = this.years;
|
|
if (i != 0) {
|
|
sb.append(i);
|
|
sb.append('Y');
|
|
}
|
|
int i2 = this.months;
|
|
if (i2 != 0) {
|
|
sb.append(i2);
|
|
sb.append('M');
|
|
}
|
|
int i3 = this.days;
|
|
if (i3 != 0) {
|
|
sb.append(i3);
|
|
sb.append('D');
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
public final long toTotalMonths() {
|
|
return (this.years * 12) + this.months;
|
|
}
|
|
|
|
@Override // o.gsT
|
|
public final boolean isZero() {
|
|
return this == ZERO;
|
|
}
|
|
|
|
@Override // o.gsT
|
|
public final boolean isNegative() {
|
|
return this.years < 0 || this.months < 0 || this.days < 0;
|
|
}
|
|
|
|
public final int getYears() {
|
|
return this.years;
|
|
}
|
|
|
|
public final int getMonths() {
|
|
return this.months;
|
|
}
|
|
|
|
public final int getDays() {
|
|
return this.days;
|
|
}
|
|
|
|
private Object readResolve() {
|
|
return ((this.years | this.months) | this.days) == 0 ? ZERO : this;
|
|
}
|
|
}
|