package com.tencent.mm.pluginsdk.f;

import android.content.Context;
import android.text.format.DateFormat;
import android.text.format.Time;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.sdk.platformtools.aa;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.ytcommon.BuildConfig;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;

public final class h {
    private static boolean vdA = false;
    private static long vdz;

    public static String formatTime(String str, long j) {
        AppMethodBeat.i(79456);
        String format = new SimpleDateFormat(str).format(new Date(1000 * j));
        AppMethodBeat.o(79456);
        return format;
    }

    public static String ae(Context context, int i) {
        AppMethodBeat.i(79457);
        long j = 1000 * ((long) i);
        GregorianCalendar gregorianCalendar = new GregorianCalendar();
        String str;
        if (j < 3600000) {
            str = BuildConfig.FLAVOR;
            AppMethodBeat.o(79457);
            return str;
        }
        GregorianCalendar gregorianCalendar2 = new GregorianCalendar(gregorianCalendar.get(1), gregorianCalendar.get(2), gregorianCalendar.get(5));
        long timeInMillis = j - gregorianCalendar2.getTimeInMillis();
        if (timeInMillis < 0 || timeInMillis >= 86400000) {
            timeInMillis = j - (gregorianCalendar2.getTimeInMillis() - 86400000);
            if (timeInMillis < 0 || timeInMillis >= 86400000) {
                timeInMillis = j - (gregorianCalendar2.getTimeInMillis() - 172800000);
                if (timeInMillis < 0 || timeInMillis >= 86400000) {
                    timeInMillis = j - (gregorianCalendar2.getTimeInMillis() + 86400000);
                    if (timeInMillis < 0 || timeInMillis >= 86400000) {
                        timeInMillis = j - (gregorianCalendar2.getTimeInMillis() + 172800000);
                        if (timeInMillis < 0 || timeInMillis >= 86400000) {
                            gregorianCalendar2 = new GregorianCalendar();
                            gregorianCalendar2.setTimeInMillis(j);
                            int i2 = gregorianCalendar2.get(11);
                            if (gregorianCalendar.get(1) == gregorianCalendar2.get(1) && gregorianCalendar.get(3) == gregorianCalendar2.get(3)) {
                                str = af(context, gregorianCalendar2.get(7)) + " " + ag(context, i2) + ";" + aJ(context.getString(2131299963), j);
                                AppMethodBeat.o(79457);
                                return str;
                            } else if (gregorianCalendar.get(1) == gregorianCalendar2.get(1) && gregorianCalendar.get(3) + 1 == gregorianCalendar2.get(3)) {
                                int i3 = gregorianCalendar2.get(7);
                                StringBuilder stringBuilder = new StringBuilder();
                                switch (i3) {
                                    case 1:
                                        str = context.getString(2131299973);
                                        break;
                                    case 2:
                                        str = context.getString(2131299971);
                                        break;
                                    case 3:
                                        str = context.getString(2131299975);
                                        break;
                                    case 4:
                                        str = context.getString(2131299976);
                                        break;
                                    case 5:
                                        str = context.getString(2131299974);
                                        break;
                                    case 6:
                                        str = context.getString(2131299970);
                                        break;
                                    case 7:
                                        str = context.getString(2131299972);
                                        break;
                                    default:
                                        str = BuildConfig.FLAVOR;
                                        break;
                                }
                                str = stringBuilder.append(str).append(" ").append(ag(context, i2)).append(";").append(aJ(context.getString(2131299963), j)).toString();
                                AppMethodBeat.o(79457);
                                return str;
                            } else if (gregorianCalendar.get(1) == gregorianCalendar2.get(1)) {
                                str = DateFormat.format(context.getString(2131299933), j) + " " + ag(context, i2) + ";" + aJ(context.getString(2131299963), j);
                                AppMethodBeat.o(79457);
                                return str;
                            } else {
                                str = DateFormat.format(context.getString(2131299952), j) + " " + ag(context, i2) + ";" + aJ(context.getString(2131299963), j);
                                AppMethodBeat.o(79457);
                                return str;
                            }
                        }
                        str = context.getString(2131299968) + " " + r(context, timeInMillis) + ";" + aJ(context.getString(2131299963), j);
                        AppMethodBeat.o(79457);
                        return str;
                    }
                    str = context.getString(2131299978) + " " + r(context, timeInMillis) + ";" + aJ(context.getString(2131299963), j);
                    AppMethodBeat.o(79457);
                    return str;
                }
                str = context.getString(2131299969) + " " + r(context, timeInMillis) + ";" + aJ(context.getString(2131299963), j);
                AppMethodBeat.o(79457);
                return str;
            }
            str = context.getString(2131299986) + " " + r(context, timeInMillis) + ";" + aJ(context.getString(2131299963), j);
            AppMethodBeat.o(79457);
            return str;
        }
        str = r(context, timeInMillis) + ";" + aJ(context.getString(2131299963), j);
        AppMethodBeat.o(79457);
        return str;
    }

    public static String aJ(String str, long j) {
        AppMethodBeat.i(79458);
        String charSequence = DateFormat.format(str, j).toString();
        if (bo.isNullOrNil(charSequence)) {
            charSequence = BuildConfig.FLAVOR;
            AppMethodBeat.o(79458);
            return charSequence;
        }
        charSequence = charSequence.trim();
        if (charSequence.startsWith("0")) {
            charSequence = charSequence.substring(1);
        }
        AppMethodBeat.o(79458);
        return charSequence;
    }

    public static String af(Context context, int i) {
        AppMethodBeat.i(79459);
        String string;
        switch (i) {
            case 1:
                string = context.getString(2131299982);
                AppMethodBeat.o(79459);
                return string;
            case 2:
                string = context.getString(2131299980);
                AppMethodBeat.o(79459);
                return string;
            case 3:
                string = context.getString(2131299984);
                AppMethodBeat.o(79459);
                return string;
            case 4:
                string = context.getString(2131299985);
                AppMethodBeat.o(79459);
                return string;
            case 5:
                string = context.getString(2131299983);
                AppMethodBeat.o(79459);
                return string;
            case 6:
                string = context.getString(2131299979);
                AppMethodBeat.o(79459);
                return string;
            case 7:
                string = context.getString(2131299981);
                AppMethodBeat.o(79459);
                return string;
            default:
                string = BuildConfig.FLAVOR;
                AppMethodBeat.o(79459);
                return string;
        }
    }

    public static CharSequence p(Context context, long j) {
        AppMethodBeat.i(79460);
        String str = context.getString(2131300011) + DateFormat.format(context.getString(2131300010), j);
        AppMethodBeat.o(79460);
        return str;
    }

    public static CharSequence q(Context context, long j) {
        AppMethodBeat.i(79461);
        String str = context.getString(2131300012) + DateFormat.format(context.getString(2131300010), j);
        AppMethodBeat.o(79461);
        return str;
    }

    private static CharSequence ag(Context context, int i) {
        AppMethodBeat.i(79462);
        CharSequence string;
        if (i < 0) {
            String str = BuildConfig.FLAVOR;
            AppMethodBeat.o(79462);
            return str;
        } else if (((long) i) < 6) {
            string = context.getString(2131299937);
            AppMethodBeat.o(79462);
            return string;
        } else if (((long) i) < 12) {
            string = context.getString(2131299956);
            AppMethodBeat.o(79462);
            return string;
        } else if (((long) i) < 13) {
            string = context.getString(2131299962);
            AppMethodBeat.o(79462);
            return string;
        } else if (((long) i) < 18) {
            string = context.getString(2131299923);
            AppMethodBeat.o(79462);
            return string;
        } else {
            string = context.getString(2131299944);
            AppMethodBeat.o(79462);
            return string;
        }
    }

    public static CharSequence r(Context context, long j) {
        AppMethodBeat.i(79463);
        CharSequence string;
        if (j < 0) {
            String str = BuildConfig.FLAVOR;
            AppMethodBeat.o(79463);
            return str;
        } else if (j < 21600000) {
            string = context.getString(2131299937);
            AppMethodBeat.o(79463);
            return string;
        } else if (j < 43200000) {
            string = context.getString(2131299956);
            AppMethodBeat.o(79463);
            return string;
        } else if (j < 46800000) {
            string = context.getString(2131299962);
            AppMethodBeat.o(79463);
            return string;
        } else if (j < 64800000) {
            string = context.getString(2131299923);
            AppMethodBeat.o(79463);
            return string;
        } else {
            string = context.getString(2131299944);
            AppMethodBeat.o(79463);
            return string;
        }
    }

    public static boolean dhT() {
        AppMethodBeat.i(79464);
        if (System.currentTimeMillis() - vdz > 30000) {
            vdA = DateFormat.is24HourFormat(ah.getContext());
        }
        boolean z = vdA;
        AppMethodBeat.o(79464);
        return z;
    }

    public static CharSequence c(Context context, long j, boolean z) {
        AppMethodBeat.i(79465);
        CharSequence charSequence;
        if (!aa.doo()) {
            Locale amw = aa.amw(aa.dor());
            GregorianCalendar gregorianCalendar = new GregorianCalendar();
            if (j < 3600000) {
                String str = BuildConfig.FLAVOR;
                AppMethodBeat.o(79465);
                return str;
            }
            GregorianCalendar gregorianCalendar2 = new GregorianCalendar(gregorianCalendar.get(1), gregorianCalendar.get(2), gregorianCalendar.get(5));
            long timeInMillis = j - gregorianCalendar2.getTimeInMillis();
            if (timeInMillis <= 0 || timeInMillis > 86400000) {
                long timeInMillis2 = (j - gregorianCalendar2.getTimeInMillis()) + 86400000;
                if (timeInMillis2 <= 0 || timeInMillis2 > 86400000) {
                    gregorianCalendar2 = new GregorianCalendar();
                    gregorianCalendar2.setTimeInMillis(j);
                    if (gregorianCalendar.get(1) == gregorianCalendar2.get(1) && gregorianCalendar.get(3) == gregorianCalendar2.get(3)) {
                        charSequence = new SimpleDateFormat("E", amw).format(Long.valueOf(j));
                        if (z) {
                            AppMethodBeat.o(79465);
                            return charSequence;
                        }
                        charSequence = charSequence + " " + java.text.DateFormat.getTimeInstance(3, amw).format(Long.valueOf(j));
                        AppMethodBeat.o(79465);
                        return charSequence;
                    } else if (gregorianCalendar.get(1) == gregorianCalendar2.get(1)) {
                        if (z) {
                            charSequence = java.text.DateFormat.getDateInstance(3, amw).format(Long.valueOf(j));
                            AppMethodBeat.o(79465);
                            return charSequence;
                        }
                        charSequence = java.text.DateFormat.getDateTimeInstance(3, 3, amw).format(Long.valueOf(j));
                        AppMethodBeat.o(79465);
                        return charSequence;
                    } else if (z) {
                        charSequence = java.text.DateFormat.getDateInstance(3, amw).format(Long.valueOf(j));
                        AppMethodBeat.o(79465);
                        return charSequence;
                    } else {
                        charSequence = java.text.DateFormat.getDateTimeInstance(3, 3, amw).format(Long.valueOf(j));
                        AppMethodBeat.o(79465);
                        return charSequence;
                    }
                } else if (z) {
                    charSequence = context.getString(2131299986);
                    AppMethodBeat.o(79465);
                    return charSequence;
                } else {
                    charSequence = context.getString(2131299986) + " " + java.text.DateFormat.getTimeInstance(3, amw).format(Long.valueOf(j));
                    AppMethodBeat.o(79465);
                    return charSequence;
                }
            }
            charSequence = java.text.DateFormat.getTimeInstance(3, amw).format(Long.valueOf(j));
            AppMethodBeat.o(79465);
            return charSequence;
        } else if (j < 3600000) {
            charSequence = BuildConfig.FLAVOR;
            AppMethodBeat.o(79465);
            return charSequence;
        } else {
            Time time = new Time();
            Time time2 = new Time();
            time.set(j);
            time2.setToNow();
            if (time.year == time2.year && time.yearDay == time2.yearDay) {
                if (dhT()) {
                    charSequence = g.a(context.getString(2131299964), time);
                    AppMethodBeat.o(79465);
                    return charSequence;
                }
                charSequence = ag(context, time.hour) + g.a(context.getString(2131299963), time);
                AppMethodBeat.o(79465);
                return charSequence;
            } else if (time.year == time2.year && time2.yearDay - time.yearDay == 1) {
                boolean dhT = dhT();
                if (z) {
                    charSequence = context.getString(2131299986);
                    AppMethodBeat.o(79465);
                    return charSequence;
                }
                Object a;
                StringBuilder append = new StringBuilder().append(context.getString(2131299986)).append(" ");
                if (dhT) {
                    a = g.a(context.getString(2131299964), time);
                } else {
                    a = ag(context, time.hour) + g.a(context.getString(2131299963), time);
                }
                charSequence = append.append(a).toString();
                AppMethodBeat.o(79465);
                return charSequence;
            } else if (time.year == time2.year && time.getWeekNumber() == time2.getWeekNumber()) {
                charSequence = g.a("E ", time);
                if (z) {
                    AppMethodBeat.o(79465);
                    return charSequence;
                }
                charSequence = charSequence + g.a(context.getString(2131299965), time);
                AppMethodBeat.o(79465);
                return charSequence;
            } else if (time.year == time2.year) {
                if (z) {
                    charSequence = g.a(context.getString(2131299933), time);
                    AppMethodBeat.o(79465);
                    return charSequence;
                }
                charSequence = g.a(context.getString(2131299935, new Object[]{r(context, ((long) time.hour) * 3600000)}).toString(), time);
                AppMethodBeat.o(79465);
                return charSequence;
            } else if (z) {
                charSequence = g.a(context.getString(2131299952), time);
                AppMethodBeat.o(79465);
                return charSequence;
            } else {
                charSequence = g.a(context.getString(2131299954, new Object[]{r(context, ((long) time.hour) * 3600000)}).toString(), time);
                AppMethodBeat.o(79465);
                return charSequence;
            }
        }
    }
}
