package org.joda.time.field;

import org.joda.time.DateTimeFieldType;

/* loaded from: classes5.dex */
public class c extends b {

    /* renamed from: r, reason: collision with root package name */
    final int f32035r;

    /* renamed from: s, reason: collision with root package name */
    final org.joda.time.d f32036s;

    /* renamed from: t, reason: collision with root package name */
    final org.joda.time.d f32037t;

    /* renamed from: u, reason: collision with root package name */
    private final int f32038u;

    /* renamed from: v, reason: collision with root package name */
    private final int f32039v;

    public c(org.joda.time.b bVar, DateTimeFieldType dateTimeFieldType, int i10) {
        this(bVar, bVar.r(), dateTimeFieldType, i10);
    }

    private int K(int i10) {
        if (i10 >= 0) {
            return i10 % this.f32035r;
        }
        int i11 = this.f32035r;
        return (i11 - 1) + ((i10 + 1) % i11);
    }

    @Override // org.joda.time.field.b, org.joda.time.field.a, org.joda.time.b
    public long C(long j10, int i10) {
        d.h(this, i10, this.f32038u, this.f32039v);
        return J().C(j10, (i10 * this.f32035r) + K(J().c(j10)));
    }

    @Override // org.joda.time.field.a, org.joda.time.b
    public long a(long j10, int i10) {
        return J().a(j10, i10 * this.f32035r);
    }

    @Override // org.joda.time.field.a, org.joda.time.b
    public long b(long j10, long j11) {
        return J().b(j10, j11 * this.f32035r);
    }

    @Override // org.joda.time.field.b, org.joda.time.field.a, org.joda.time.b
    public int c(long j10) {
        int c10 = J().c(j10);
        return c10 >= 0 ? c10 / this.f32035r : ((c10 + 1) / this.f32035r) - 1;
    }

    @Override // org.joda.time.field.a, org.joda.time.b
    public int j(long j10, long j11) {
        return J().j(j10, j11) / this.f32035r;
    }

    @Override // org.joda.time.field.a, org.joda.time.b
    public long k(long j10, long j11) {
        return J().k(j10, j11) / this.f32035r;
    }

    @Override // org.joda.time.field.b, org.joda.time.field.a, org.joda.time.b
    public org.joda.time.d l() {
        return this.f32036s;
    }

    @Override // org.joda.time.field.b, org.joda.time.field.a, org.joda.time.b
    public int o() {
        return this.f32039v;
    }

    @Override // org.joda.time.field.b, org.joda.time.b
    public int p() {
        return this.f32038u;
    }

    @Override // org.joda.time.field.b, org.joda.time.b
    public org.joda.time.d r() {
        org.joda.time.d dVar = this.f32037t;
        return dVar != null ? dVar : super.r();
    }

    @Override // org.joda.time.field.a, org.joda.time.b
    public long w(long j10) {
        return C(j10, c(J().w(j10)));
    }

    @Override // org.joda.time.field.a, org.joda.time.b
    public long y(long j10) {
        org.joda.time.b J = J();
        return J.y(J.C(j10, c(j10) * this.f32035r));
    }

    public c(org.joda.time.b bVar, org.joda.time.d dVar, DateTimeFieldType dateTimeFieldType, int i10) {
        super(bVar, dateTimeFieldType);
        if (i10 >= 2) {
            org.joda.time.d l10 = bVar.l();
            if (l10 == null) {
                this.f32036s = null;
            } else {
                this.f32036s = new ScaledDurationField(l10, dateTimeFieldType.E(), i10);
            }
            this.f32037t = dVar;
            this.f32035r = i10;
            int p10 = bVar.p();
            int i11 = p10 >= 0 ? p10 / i10 : ((p10 + 1) / i10) - 1;
            int o10 = bVar.o();
            int i12 = o10 >= 0 ? o10 / i10 : ((o10 + 1) / i10) - 1;
            this.f32038u = i11;
            this.f32039v = i12;
            return;
        }
        throw new IllegalArgumentException("The divisor must be at least 2");
    }
}
