package com.seewo.ota.util;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;

/* JADX INFO: compiled from: CalendarExt.kt */
/* JADX INFO: loaded from: classes.dex */
public final class i {
    public static final Calendar a(int i2, int i3) {
        Calendar calendar = Calendar.getInstance();
        long timeInMillis = calendar.getTimeInMillis();
        if (i3 == 2) {
            calendar.set(2, i2);
            if (timeInMillis > calendar.getTimeInMillis()) {
                calendar.add(1, 1);
            }
        } else if (i3 == 5) {
            calendar.set(5, i2);
            if (timeInMillis > calendar.getTimeInMillis()) {
                calendar.add(2, 1);
            }
        } else if (i3 == 11) {
            calendar.set(11, i2);
            if (timeInMillis > calendar.getTimeInMillis()) {
                calendar.add(5, 1);
            }
        } else {
            if (i3 != 12) {
                throw new IllegalArgumentException("unit is not supported");
            }
            calendar.set(12, i2);
            if (timeInMillis > calendar.getTimeInMillis()) {
                calendar.add(11, 1);
            }
        }
        f.z.d.k.d(calendar, "calendar");
        return calendar;
    }

    public static final Calendar b(Calendar calendar, int i2) {
        f.z.d.k.e(calendar, "<this>");
        if (i2 == 2) {
            calendar.add(1, 1);
        } else if (i2 == 5) {
            calendar.add(2, 1);
        } else if (i2 == 11) {
            calendar.add(5, 1);
        } else {
            if (i2 != 12) {
                throw new IllegalArgumentException("unit is not supported");
            }
            calendar.add(11, 1);
        }
        return calendar;
    }

    public static final f.k<Calendar, Integer> c(String str) throws IllegalArgumentException {
        f.z.d.k.e(str, "<this>");
        List listN = f.e0.t.N(str, new String[]{"-"}, false, 0, 6, null);
        ArrayList arrayList = new ArrayList(f.u.l.j(listN, 10));
        Iterator it = listN.iterator();
        while (it.hasNext()) {
            arrayList.add(Integer.valueOf(Integer.parseInt((String) it.next())));
        }
        if (arrayList.size() != 2) {
            throw new IllegalArgumentException("params size is not 2");
        }
        int iIntValue = ((Number) arrayList.get(0)).intValue();
        int iIntValue2 = ((Number) arrayList.get(1)).intValue();
        return new f.k<>(a(iIntValue, iIntValue2), Integer.valueOf(iIntValue2));
    }
}
