/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  android.util.Log
 *  java.lang.Object
 *  java.lang.String
 *  java.lang.StringBuffer
 *  java.lang.System
 *  java.lang.Throwable
 *  java.util.Calendar
 *  java.util.Date
 */
package com.google.code.microlog4android.format.command;

import android.util.Log;
import com.google.code.microlog4android.Level;
import com.google.code.microlog4android.format.command.FormatCommandInterface;
import java.util.Calendar;
import java.util.Date;

public class DateFormatCommand
implements FormatCommandInterface {
    public static final int ABSOLUTE_FORMAT = 1;
    public static final String ABSOLUTE_FORMAT_STRING = "ABSOLUTE";
    public static final int DATE_FORMAT = 2;
    public static final String DATE_FORMAT_STRING = "DATE";
    public static final int ISO_8601_FORMAT = 3;
    public static final String ISO_8601_FORMAT_STRING = "ISO8601";
    static final String[] MONTH_ARRAY;
    private static final String TAG = "Microlog.DateFormatCommand";
    public static int USER_FORMAT;
    private final Calendar calendar = Calendar.getInstance();
    int format = 1;

    static {
        USER_FORMAT = 0;
        MONTH_ARRAY = new String[]{"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
    }

    @Override
    public String execute(String string2, String string3, long l, Level level, Object object, Throwable throwable) {
        long l2 = System.currentTimeMillis();
        switch (this.format) {
            default: {
                Log.e((String)"Microlog.DateFormatCommand", (String)"Unrecognized format, using default format.");
                return this.toAbsoluteFormat(System.currentTimeMillis());
            }
            case 1: {
                return this.toAbsoluteFormat(l2);
            }
            case 2: {
                return this.toDateFormat(l2);
            }
            case 3: 
        }
        return this.toISO8601Format(l2);
    }

    /*
     * Enabled aggressive block sorting
     */
    @Override
    public void init(String string2) {
        if (string2.equals((Object)"ABSOLUTE")) {
            this.format = 1;
            return;
        } else {
            if (string2.equals((Object)"DATE")) {
                this.format = 2;
                return;
            }
            if (!string2.equals((Object)"ISO8601")) return;
            {
                this.format = 3;
                return;
            }
        }
    }

    String toAbsoluteFormat(long l) {
        this.calendar.setTime(new Date(l));
        long l2 = this.calendar.get(11);
        StringBuffer stringBuffer = new StringBuffer();
        if (l2 < 10) {
            stringBuffer.append('0');
        }
        stringBuffer.append(l2);
        stringBuffer.append(':');
        long l3 = this.calendar.get(12);
        if (l3 < 10) {
            stringBuffer.append('0');
        }
        stringBuffer.append(l3);
        stringBuffer.append(':');
        long l4 = this.calendar.get(13);
        if (l4 < 10) {
            stringBuffer.append('0');
        }
        stringBuffer.append(l4);
        stringBuffer.append(',');
        long l5 = this.calendar.get(14);
        if (l5 < 10) {
            stringBuffer.append('0');
        }
        stringBuffer.append(l5);
        return stringBuffer.toString();
    }

    String toDateFormat(long l) {
        this.calendar.setTime(new Date(l));
        StringBuffer stringBuffer = new StringBuffer();
        int n = this.calendar.get(5);
        if (n < 10) {
            stringBuffer.append('0');
        }
        stringBuffer.append(n);
        stringBuffer.append(' ');
        int n2 = this.calendar.get(2);
        stringBuffer.append(MONTH_ARRAY[n2]);
        stringBuffer.append(' ');
        stringBuffer.append(this.calendar.get(1));
        stringBuffer.append(' ');
        stringBuffer.append(this.toAbsoluteFormat(l));
        return stringBuffer.toString();
    }

    String toISO8601Format(long l) {
        this.calendar.setTime(new Date(l));
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append(this.calendar.get(1));
        stringBuffer.append('-');
        int n = 1 + this.calendar.get(2);
        if (n < 10) {
            stringBuffer.append('0');
        }
        stringBuffer.append(n);
        stringBuffer.append('-');
        int n2 = this.calendar.get(5);
        if (n2 < 10) {
            stringBuffer.append('0');
        }
        stringBuffer.append(n2);
        stringBuffer.append(' ');
        stringBuffer.append(this.toAbsoluteFormat(l));
        return stringBuffer.toString();
    }
}

