package j$.time;

import defpackage.C5224;
import j$.time.chrono.ChronoLocalDateTime;
import j$.time.format.DateTimeFormatter;
import j$.time.temporal.ChronoUnit;
import j$.time.temporal.Temporal;
import j$.time.temporal.TemporalAccessor;
import j$.time.temporal.TemporalUnit;
import j$.util.Objects;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.Serializable;

/* JADX INFO: compiled from: r8-map-id-da1bda724d8b26dc30f90d2ccf434f42461d6c82e7dbdeb074f412e5504de99c */
/* JADX INFO: loaded from: classes2.dex */
public final class LocalDateTime implements Temporal, j$.time.temporal.l, ChronoLocalDateTime<LocalDate>, Serializable {
    public static final LocalDateTime c = V(LocalDate.d, j.e);
    public static final LocalDateTime d = V(LocalDate.e, j.f);
    private static final long serialVersionUID = 6207766400415563566L;
    public final LocalDate a;
    public final j b;

    public LocalDateTime(LocalDate localDate, j jVar) {
        this.a = localDate;
        this.b = jVar;
    }

    public static LocalDateTime T(TemporalAccessor temporalAccessor) {
        if (temporalAccessor instanceof LocalDateTime) {
            return (LocalDateTime) temporalAccessor;
        }
        if (temporalAccessor instanceof ZonedDateTime) {
            return ((ZonedDateTime) temporalAccessor).a;
        }
        if (temporalAccessor instanceof OffsetDateTime) {
            return ((OffsetDateTime) temporalAccessor).toLocalDateTime();
        }
        try {
            return new LocalDateTime(LocalDate.U(temporalAccessor), j.U(temporalAccessor));
        } catch (DateTimeException e) {
            g.h("Unable to obtain LocalDateTime from TemporalAccessor: ", temporalAccessor, temporalAccessor.getClass().getName(), e);
            return null;
        }
    }

    public static LocalDateTime V(LocalDate localDate, j jVar) {
        Objects.requireNonNull(localDate, "date");
        Objects.requireNonNull(jVar, "time");
        return new LocalDateTime(localDate, jVar);
    }

    public static LocalDateTime W(long j, int i, ZoneOffset zoneOffset) {
        Objects.requireNonNull(zoneOffset, "offset");
        long j2 = i;
        j$.time.temporal.a.NANO_OF_SECOND.G(j2);
        long j3 = j + ((long) zoneOffset.b);
        return new LocalDateTime(LocalDate.d0(j$.com.android.tools.r8.a.X(j3, 86400L)), j.X((((long) ((int) j$.com.android.tools.r8.a.W(j3, 86400L))) * 1000000000) + j2));
    }

    public static LocalDateTime now() {
        a aVarF0 = j$.com.android.tools.r8.a.f0();
        Objects.requireNonNull(aVarF0, "clock");
        Instant instantOfEpochMilli = Instant.ofEpochMilli(System.currentTimeMillis());
        return W(instantOfEpochMilli.a, instantOfEpochMilli.b, aVarF0.a.T().d(instantOfEpochMilli));
    }

    public static LocalDateTime ofInstant(Instant instant, ZoneId zoneId) {
        Objects.requireNonNull(instant, "instant");
        Objects.requireNonNull(zoneId, "zone");
        return W(instant.a, instant.b, zoneId.T().d(instant));
    }

    public static LocalDateTime parse(CharSequence charSequence, DateTimeFormatter dateTimeFormatter) {
        Objects.requireNonNull(dateTimeFormatter, "formatter");
        return (LocalDateTime) dateTimeFormatter.a(charSequence, new f(1));
    }

    private void readObject(ObjectInputStream objectInputStream) throws InvalidObjectException {
        throw new InvalidObjectException("Deserialization via serialization delegate");
    }

    private Object writeReplace() {
        return new s((byte) 5, this);
    }

    @Override // j$.time.temporal.Temporal
    /* JADX INFO: renamed from: A */
    public final Temporal u(long j, ChronoUnit chronoUnit) {
        long j2;
        if (j == Long.MIN_VALUE) {
            this = d(Long.MAX_VALUE, chronoUnit);
            j2 = 1;
        } else {
            j2 = -j;
        }
        return this.d(j2, chronoUnit);
    }

    @Override // j$.time.temporal.TemporalAccessor
    public final long E(j$.time.temporal.o oVar) {
        return oVar instanceof j$.time.temporal.a ? ((j$.time.temporal.a) oVar).S() ? this.b.E(oVar) : this.a.E(oVar) : oVar.A(this);
    }

    @Override // j$.time.temporal.TemporalAccessor
    public final Object G(f fVar) {
        return fVar == j$.time.temporal.p.f ? this.a : j$.com.android.tools.r8.a.w(this, fVar);
    }

    @Override // java.lang.Comparable
    /* JADX INFO: renamed from: K, reason: merged with bridge method [inline-methods] */
    public final int compareTo(ChronoLocalDateTime chronoLocalDateTime) {
        return chronoLocalDateTime instanceof LocalDateTime ? S((LocalDateTime) chronoLocalDateTime) : j$.com.android.tools.r8.a.g(this, chronoLocalDateTime);
    }

    public final int S(LocalDateTime localDateTime) {
        int iS = this.a.S(localDateTime.f());
        return iS == 0 ? this.b.compareTo(localDateTime.b) : iS;
    }

    public final boolean U(ChronoLocalDateTime chronoLocalDateTime) {
        if (chronoLocalDateTime instanceof LocalDateTime) {
            return S((LocalDateTime) chronoLocalDateTime) < 0;
        }
        long jF = f().F();
        long jF2 = chronoLocalDateTime.f().F();
        if (jF >= jF2) {
            return jF == jF2 && this.b.e0() < chronoLocalDateTime.b().e0();
        }
        return true;
    }

    @Override // j$.time.temporal.Temporal
    /* JADX INFO: renamed from: X, reason: merged with bridge method [inline-methods] */
    public final LocalDateTime d(long j, TemporalUnit temporalUnit) {
        if (!(temporalUnit instanceof ChronoUnit)) {
            return (LocalDateTime) temporalUnit.k(this, j);
        }
        switch (h.a[((ChronoUnit) temporalUnit).ordinal()]) {
            case 1:
                return Y(this.a, 0L, 0L, 0L, j, 1);
            case 2:
                LocalDateTime localDateTimePlusDays = plusDays(j / 86400000000L);
                return localDateTimePlusDays.Y(localDateTimePlusDays.a, 0L, 0L, 0L, (j % 86400000000L) * 1000, 1);
            case 3:
                LocalDateTime localDateTimePlusDays2 = plusDays(j / 86400000);
                return localDateTimePlusDays2.Y(localDateTimePlusDays2.a, 0L, 0L, 0L, (j % 86400000) * 1000000, 1);
            case 4:
                return plusSeconds(j);
            case 5:
                return Y(this.a, 0L, j, 0L, 0L, 1);
            case C5224.STRING_SET_FIELD_NUMBER /* 6 */:
                return Y(this.a, j, 0L, 0L, 0L, 1);
            case C5224.DOUBLE_FIELD_NUMBER /* 7 */:
                LocalDateTime localDateTimePlusDays3 = plusDays(j / 256);
                return localDateTimePlusDays3.Y(localDateTimePlusDays3.a, (j % 256) * 12, 0L, 0L, 0L, 1);
            default:
                return a0(this.a.d(j, temporalUnit), this.b);
        }
    }

    public final LocalDateTime Y(LocalDate localDate, long j, long j2, long j3, long j4, int i) {
        long j5 = j | j2 | j3 | j4;
        j jVar = this.b;
        if (j5 == 0) {
            return a0(localDate, jVar);
        }
        long j6 = i;
        long jE0 = jVar.e0();
        long j7 = ((((j % 24) * 3600000000000L) + ((j2 % 1440) * 60000000000L) + ((j3 % 86400) * 1000000000) + (j4 % 86400000000000L)) * j6) + jE0;
        long jX = j$.com.android.tools.r8.a.X(j7, 86400000000000L) + (((j / 24) + (j2 / 1440) + (j3 / 86400) + (j4 / 86400000000000L)) * j6);
        long jW = j$.com.android.tools.r8.a.W(j7, 86400000000000L);
        return a0(localDate.plusDays(jX), jW == jE0 ? this.b : j.X(jW));
    }

    @Override // j$.time.temporal.Temporal
    /* JADX INFO: renamed from: Z, reason: merged with bridge method [inline-methods] */
    public final LocalDateTime c(long j, j$.time.temporal.o oVar) {
        if (!(oVar instanceof j$.time.temporal.a)) {
            return (LocalDateTime) oVar.E(this, j);
        }
        boolean zS = ((j$.time.temporal.a) oVar).S();
        LocalDate localDate = this.a;
        return zS ? a0(localDate, this.b.c(j, oVar)) : a0(localDate.c(j, oVar), this.b);
    }

    @Override // j$.time.chrono.ChronoLocalDateTime
    public final j$.time.chrono.j a() {
        return ((LocalDate) f()).a();
    }

    public final LocalDateTime a0(LocalDate localDate, j jVar) {
        return (this.a == localDate && this.b == jVar) ? this : new LocalDateTime(localDate, jVar);
    }

    @Override // j$.time.chrono.ChronoLocalDateTime
    /* JADX INFO: renamed from: atZone, reason: merged with bridge method [inline-methods] */
    public ZonedDateTime B(ZoneId zoneId) {
        return ZonedDateTime.T(this, zoneId, null);
    }

    @Override // j$.time.chrono.ChronoLocalDateTime
    public final j b() {
        return this.b;
    }

    @Override // j$.time.temporal.Temporal
    /* JADX INFO: renamed from: b0, reason: merged with bridge method [inline-methods] */
    public final LocalDateTime z(j$.time.temporal.l lVar) {
        return lVar instanceof LocalDate ? a0((LocalDate) lVar, this.b) : lVar instanceof j ? a0(this.a, (j) lVar) : lVar instanceof LocalDateTime ? (LocalDateTime) lVar : (LocalDateTime) lVar.q(this);
    }

    @Override // j$.time.temporal.TemporalAccessor
    public final boolean e(j$.time.temporal.o oVar) {
        if (!(oVar instanceof j$.time.temporal.a)) {
            return oVar != null && oVar.k(this);
        }
        j$.time.temporal.a aVar = (j$.time.temporal.a) oVar;
        return aVar.isDateBased() || aVar.S();
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof LocalDateTime) {
            LocalDateTime localDateTime = (LocalDateTime) obj;
            if (this.a.equals(localDateTime.a) && this.b.equals(localDateTime.b)) {
                return true;
            }
        }
        return false;
    }

    public String format(DateTimeFormatter dateTimeFormatter) {
        Objects.requireNonNull(dateTimeFormatter, "formatter");
        return dateTimeFormatter.format(this);
    }

    public int getDayOfMonth() {
        return this.a.c;
    }

    public DayOfWeek getDayOfWeek() {
        return this.a.W();
    }

    public int getHour() {
        return this.b.a;
    }

    public int getMinute() {
        return this.b.b;
    }

    public int getMonthValue() {
        return this.a.b;
    }

    public int getYear() {
        return this.a.getYear();
    }

    public final int hashCode() {
        return this.b.hashCode() ^ this.a.hashCode();
    }

    @Override // j$.time.temporal.TemporalAccessor
    public final int k(j$.time.temporal.o oVar) {
        return oVar instanceof j$.time.temporal.a ? ((j$.time.temporal.a) oVar).S() ? this.b.k(oVar) : this.a.k(oVar) : j$.time.temporal.p.a(this, oVar);
    }

    @Override // j$.time.temporal.TemporalAccessor
    public final j$.time.temporal.r m(j$.time.temporal.o oVar) {
        if (!(oVar instanceof j$.time.temporal.a)) {
            return oVar.l(this);
        }
        if (!((j$.time.temporal.a) oVar).S()) {
            return this.a.m(oVar);
        }
        j jVar = this.b;
        jVar.getClass();
        return j$.time.temporal.p.d(jVar, oVar);
    }

    public LocalDateTime minusMinutes(long j) {
        return Y(this.a, 0L, j, 0L, 0L, -1);
    }

    public LocalDateTime plusDays(long j) {
        return a0(this.a.plusDays(j), this.b);
    }

    public LocalDateTime plusSeconds(long j) {
        return Y(this.a, 0L, 0L, j, 0L, 1);
    }

    @Override // j$.time.temporal.l
    public final Temporal q(Temporal temporal) {
        return temporal.c(((LocalDate) f()).F(), j$.time.temporal.a.EPOCH_DAY).c(b().e0(), j$.time.temporal.a.NANO_OF_DAY);
    }

    @Override // j$.time.chrono.ChronoLocalDateTime
    public final /* synthetic */ long toEpochSecond(ZoneOffset zoneOffset) {
        return j$.com.android.tools.r8.a.z(this, zoneOffset);
    }

    @Override // j$.time.chrono.ChronoLocalDateTime
    /* JADX INFO: renamed from: toLocalDate, reason: merged with bridge method [inline-methods] */
    public LocalDate f() {
        return this.a;
    }

    public final String toString() {
        return this.a.toString() + "T" + this.b.toString();
    }

    public LocalDateTime truncatedTo(TemporalUnit temporalUnit) {
        LocalDate localDate = this.a;
        j jVarX = this.b;
        jVarX.getClass();
        if (temporalUnit != ChronoUnit.NANOS) {
            c duration = temporalUnit.getDuration();
            long j = duration.a;
            if (j > 86400) {
                throw new j$.time.temporal.q("Unit is too large to be used for truncation");
            }
            long j2 = duration.b;
            if (j < 0) {
                j++;
                j2 -= 1000000000;
            }
            long jS = j$.com.android.tools.r8.a.S(j$.com.android.tools.r8.a.Y(j, 1000000000L), j2);
            if (86400000000000L % jS != 0) {
                throw new j$.time.temporal.q("Unit must divide into a standard day without remainder");
            }
            jVarX = j.X((jVarX.e0() / jS) * jS);
        }
        return a0(localDate, jVarX);
    }

    /* JADX WARN: Removed duplicated region for block: B:30:0x00bf  */
    @Override // j$.time.temporal.Temporal
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final long until(Temporal temporal, TemporalUnit temporalUnit) {
        long jY;
        long j;
        LocalDateTime localDateTimeT = T(temporal);
        if (!(temporalUnit instanceof ChronoUnit)) {
            return temporalUnit.between(this, localDateTimeT);
        }
        ChronoUnit chronoUnit = (ChronoUnit) temporalUnit;
        if (chronoUnit.compareTo(ChronoUnit.DAYS) >= 0) {
            LocalDate localDatePlusDays = localDateTimeT.a;
            LocalDate localDate = this.a;
            boolean z = false;
            if (localDate != null) {
                localDatePlusDays.getClass();
                if (localDatePlusDays.S(localDate) > 0) {
                    z = true;
                }
            } else if (localDatePlusDays.F() > localDate.F()) {
            }
            if (z && localDateTimeT.b.compareTo(this.b) < 0) {
                localDatePlusDays = localDatePlusDays.minusDays(1L);
            } else if (localDatePlusDays.isBefore(this.a) && localDateTimeT.b.compareTo(this.b) > 0) {
                localDatePlusDays = localDatePlusDays.plusDays(1L);
            }
            return this.a.until(localDatePlusDays, temporalUnit);
        }
        LocalDate localDate2 = this.a;
        LocalDate localDate3 = localDateTimeT.a;
        localDate2.getClass();
        long jF = localDate3.F() - localDate2.F();
        if (jF == 0) {
            return this.b.until(localDateTimeT.b, temporalUnit);
        }
        long jE0 = localDateTimeT.b.e0() - this.b.e0();
        if (jF > 0) {
            jY = jF - 1;
            j = jE0 + 86400000000000L;
        } else {
            jY = jF + 1;
            j = jE0 - 86400000000000L;
        }
        switch (h.a[chronoUnit.ordinal()]) {
            case 1:
                jY = j$.com.android.tools.r8.a.Y(jY, 86400000000000L);
                break;
            case 2:
                jY = j$.com.android.tools.r8.a.Y(jY, 86400000000L);
                j /= 1000;
                break;
            case 3:
                jY = j$.com.android.tools.r8.a.Y(jY, 86400000L);
                j /= 1000000;
                break;
            case 4:
                jY = j$.com.android.tools.r8.a.Y(jY, 86400L);
                j /= 1000000000;
                break;
            case 5:
                jY = j$.com.android.tools.r8.a.Y(jY, 1440L);
                j /= 60000000000L;
                break;
            case C5224.STRING_SET_FIELD_NUMBER /* 6 */:
                jY = j$.com.android.tools.r8.a.Y(jY, 24L);
                j /= 3600000000000L;
                break;
            case C5224.DOUBLE_FIELD_NUMBER /* 7 */:
                jY = j$.com.android.tools.r8.a.Y(jY, 2L);
                j /= 43200000000000L;
                break;
        }
        return j$.com.android.tools.r8.a.S(jY, j);
    }

    public LocalDateTime withDayOfMonth(int i) {
        LocalDate localDateOf = this.a;
        if (localDateOf.c != i) {
            localDateOf = LocalDate.of(localDateOf.a, localDateOf.b, i);
        }
        return a0(localDateOf, this.b);
    }

    public LocalDateTime withHour(int i) {
        return a0(this.a, this.b.h0(i));
    }

    public LocalDateTime withMinute(int i) {
        j jVarT = this.b;
        if (jVarT.b != i) {
            j$.time.temporal.a.MINUTE_OF_HOUR.G(i);
            jVarT = j.T(jVarT.a, i, jVarT.c, jVarT.d);
        }
        return a0(this.a, jVarT);
    }

    public LocalDateTime withMonth(int i) {
        LocalDate localDateJ0 = this.a;
        if (localDateJ0.b != i) {
            j$.time.temporal.a.MONTH_OF_YEAR.G(i);
            localDateJ0 = LocalDate.j0(localDateJ0.a, i, localDateJ0.c);
        }
        return a0(localDateJ0, this.b);
    }

    public LocalDateTime withSecond(int i) {
        j jVarT = this.b;
        if (jVarT.c != i) {
            j$.time.temporal.a.SECOND_OF_MINUTE.G(i);
            jVarT = j.T(jVarT.a, jVarT.b, i, jVarT.d);
        }
        return a0(this.a, jVarT);
    }

    public LocalDateTime withYear(int i) {
        return a0(this.a.m0(i), this.b);
    }
}
