package f7;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import kotlin.jvm.internal.k;
import kotlin.jvm.internal.t;
import kotlin.text.y;
import kotlin.text.z;

/* loaded from: classes.dex */
public final class b implements Comparable {

    /* renamed from: q */
    public static final a f17939q = new a(null);

    /* renamed from: r */
    private static final DateTimeFormatter f17940r;

    /* renamed from: s */
    private static final ZoneId f17941s;

    /* renamed from: t */
    private static final DateTimeFormatter f17942t;

    /* renamed from: u */
    private static final DateTimeFormatter f17943u;

    /* renamed from: v */
    private static final b f17944v;

    /* renamed from: w */
    private static final b f17945w;

    /* renamed from: p */
    private final Instant f17946p;

    /* loaded from: classes.dex */
    public static final class a {
        private a() {
        }

        public /* synthetic */ a(k kVar) {
            this();
        }

        public static /* synthetic */ b b(a aVar, long j10, int i10, int i11, Object obj) {
            if ((i11 & 2) != 0) {
                i10 = 0;
            }
            return aVar.a(j10, i10);
        }

        public final b a(long j10, int i10) {
            Instant ofEpochSecond = Instant.ofEpochSecond(j10, i10);
            t.f(ofEpochSecond, "ofEpochSecond(...)");
            return new b(ofEpochSecond);
        }

        public final b c() {
            Instant now = Instant.now();
            t.f(now, "now(...)");
            return new b(now);
        }
    }

    /* renamed from: f7.b$b */
    /* loaded from: classes.dex */
    public /* synthetic */ class C0390b {

        /* renamed from: a */
        public static final /* synthetic */ int[] f17947a;

        static {
            int[] iArr = new int[d.values().length];
            try {
                iArr[d.ISO_8601.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[d.ISO_8601_CONDENSED.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[d.ISO_8601_CONDENSED_DATE.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                iArr[d.RFC_5322.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                iArr[d.EPOCH_SECONDS.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            f17947a = iArr;
        }
    }

    static {
        DateTimeFormatter b10;
        b10 = c.b();
        f17940r = b10;
        ZoneId of2 = ZoneId.of("Z");
        f17941s = of2;
        DateTimeFormatter withZone = DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss'Z'").withZone(of2);
        t.f(withZone, "withZone(...)");
        f17942t = withZone;
        DateTimeFormatter withZone2 = DateTimeFormatter.ofPattern("yyyyMMdd").withZone(of2);
        t.f(withZone2, "withZone(...)");
        f17943u = withZone2;
        Instant MIN = Instant.MIN;
        t.f(MIN, "MIN");
        f17944v = new b(MIN);
        Instant MAX = Instant.MAX;
        t.f(MAX, "MAX");
        f17945w = new b(MAX);
    }

    public b(Instant value) {
        t.g(value, "value");
        this.f17946p = value;
    }

    @Override // java.lang.Comparable
    /* renamed from: a */
    public int compareTo(b other) {
        t.g(other, "other");
        return this.f17946p.compareTo(other.f17946p);
    }

    public final String e(d fmt) {
        String F;
        CharSequence f12;
        t.g(fmt, "fmt");
        int i10 = C0390b.f17947a[fmt.ordinal()];
        if (i10 == 1) {
            String format = DateTimeFormatter.ISO_INSTANT.format(this.f17946p.truncatedTo(ChronoUnit.MICROS));
            t.f(format, "format(...)");
            return format;
        }
        if (i10 == 2) {
            String format2 = f17942t.format(this.f17946p);
            t.f(format2, "format(...)");
            return format2;
        }
        if (i10 == 3) {
            String format3 = f17943u.format(this.f17946p);
            t.f(format3, "format(...)");
            return format3;
        }
        if (i10 == 4) {
            String format4 = f17940r.format(ZonedDateTime.ofInstant(this.f17946p, ZoneOffset.UTC));
            t.f(format4, "format(...)");
            return format4;
        }
        if (i10 != 5) {
            throw new rm.t();
        }
        StringBuffer stringBuffer = new StringBuffer(String.valueOf(g()));
        if (m() <= 0) {
            String stringBuffer2 = stringBuffer.toString();
            t.d(stringBuffer2);
            return stringBuffer2;
        }
        stringBuffer.append(".");
        String valueOf = String.valueOf(m());
        F = y.F("0", 9 - valueOf.length());
        stringBuffer.append(F);
        stringBuffer.append(valueOf);
        f12 = z.f1(stringBuffer, '0');
        return f12.toString();
    }

    public boolean equals(Object obj) {
        return this == obj || ((obj instanceof b) && t.b(this.f17946p, ((b) obj).f17946p));
    }

    public final long g() {
        return this.f17946p.getEpochSecond();
    }

    public int hashCode() {
        return this.f17946p.hashCode();
    }

    public final int m() {
        return this.f17946p.getNano();
    }

    public final Instant r() {
        return this.f17946p;
    }

    public String toString() {
        return e(d.ISO_8601);
    }
}
