package jxl.write.biff;

import common.Logger;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import jxl.CellType;
import jxl.DateCell;
import jxl.biff.DoubleHelper;
import jxl.biff.Type;
import jxl.format.CellFormat;
import jxl.write.DateFormats;
import jxl.write.WritableCellFormat;

/* JADX INFO: loaded from: classes.dex */
public abstract class DateRecord extends CellValue {
    public static /* synthetic */ Class class$jxl$write$biff$DateRecord = null;
    public static final WritableCellFormat defaultDateFormat;
    private static Logger logger = null;
    private static final long msInADay = 86400000;
    private static final int nonLeapDay = 61;
    private static final int utcOffsetDays = 25569;
    private Date date;
    private boolean time;
    private double value;

    public static final class GMTDate {
    }

    static {
        Class clsClass$ = class$jxl$write$biff$DateRecord;
        if (clsClass$ == null) {
            clsClass$ = class$("jxl.write.biff.DateRecord");
            class$jxl$write$biff$DateRecord = clsClass$;
        }
        logger = Logger.getLogger(clsClass$);
        defaultDateFormat = new WritableCellFormat(DateFormats.DEFAULT);
    }

    public DateRecord(int i2, int i3, Date date) {
        this(i2, i3, date, (CellFormat) defaultDateFormat, true);
    }

    private void calculateValue(boolean z) {
        long j2;
        long j3 = 0;
        if (z) {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(this.date);
            j3 = calendar.get(15);
            j2 = calendar.get(16);
        } else {
            j2 = 0;
        }
        double time = (((this.date.getTime() + j3) + j2) / 8.64E7d) + 25569.0d;
        this.value = time;
        boolean z2 = this.time;
        if (!z2 && time < 61.0d) {
            this.value = time - 1.0d;
        }
        if (z2) {
            double d2 = this.value;
            this.value = d2 - ((double) ((int) d2));
        }
    }

    public static /* synthetic */ Class class$(String str) {
        try {
            return Class.forName(str);
        } catch (ClassNotFoundException e2) {
            throw new NoClassDefFoundError(e2.getMessage());
        }
    }

    @Override // jxl.write.biff.CellValue, jxl.Cell
    public String getContents() {
        return this.date.toString();
    }

    @Override // jxl.write.biff.CellValue, jxl.biff.WritableRecordData
    public byte[] getData() {
        byte[] data = super.getData();
        byte[] bArr = new byte[data.length + 8];
        System.arraycopy(data, 0, bArr, 0, data.length);
        DoubleHelper.getIEEEBytes(this.value, bArr, data.length);
        return bArr;
    }

    public Date getDate() {
        return this.date;
    }

    public DateFormat getDateFormat() {
        return null;
    }

    @Override // jxl.write.biff.CellValue, jxl.Cell
    public CellType getType() {
        return CellType.DATE;
    }

    public boolean isTime() {
        return this.time;
    }

    public void setDate(Date date) {
        this.date = date;
        calculateValue(true);
    }

    public DateRecord(int i2, int i3, Date date, GMTDate gMTDate) {
        this(i2, i3, date, (CellFormat) defaultDateFormat, false);
    }

    public DateRecord(int i2, int i3, Date date, CellFormat cellFormat) {
        super(Type.NUMBER, i2, i3, cellFormat);
        this.date = date;
        calculateValue(true);
    }

    public void setDate(Date date, GMTDate gMTDate) {
        this.date = date;
        calculateValue(false);
    }

    public DateRecord(int i2, int i3, Date date, CellFormat cellFormat, GMTDate gMTDate) {
        super(Type.NUMBER, i2, i3, cellFormat);
        this.date = date;
        calculateValue(false);
    }

    public DateRecord(int i2, int i3, Date date, CellFormat cellFormat, boolean z) {
        super(Type.NUMBER, i2, i3, cellFormat);
        this.date = date;
        this.time = z;
        calculateValue(false);
    }

    public DateRecord(DateCell dateCell) {
        super(Type.NUMBER, dateCell);
        this.date = dateCell.getDate();
        this.time = dateCell.isTime();
        calculateValue(false);
    }

    public DateRecord(int i2, int i3, DateRecord dateRecord) {
        super(Type.NUMBER, i2, i3, dateRecord);
        this.value = dateRecord.value;
        this.time = dateRecord.time;
        this.date = dateRecord.date;
    }
}
