56 lines
3.5 KiB
Java
56 lines
3.5 KiB
Java
package com.discord.utilities.duration;
|
|
|
|
import android.content.Context;
|
|
import c.a.l.b;
|
|
import com.discord.R;
|
|
import com.discord.utilities.resources.StringResourceUtilsKt;
|
|
import d0.a0.a;
|
|
import d0.z.d.m;
|
|
/* compiled from: DurationUtils.kt */
|
|
public final class DurationUtilsKt {
|
|
private static final int FEW_SECONDS_BOUNDARY = 30;
|
|
|
|
public static final CharSequence humanizeDuration(Context context, long j) {
|
|
m.checkNotNullParameter(context, "context");
|
|
if (j <= 30000) {
|
|
String string = context.getString(R.string.humanize_duration_a_few_seconds);
|
|
m.checkNotNullExpressionValue(string, "context.getString(\n …ation_a_few_seconds\n )");
|
|
return string;
|
|
} else if (j <= 60000) {
|
|
int i = (int) (j / 1000);
|
|
return b.h(context, R.string.humanize_duration_seconds, new Object[]{StringResourceUtilsKt.getI18nPluralString(context, R.plurals.humanize_duration_seconds_time, i, Integer.valueOf(i))}, null, 4);
|
|
} else if (j <= 3600000) {
|
|
int i2 = (int) (j / 60000);
|
|
return b.h(context, R.string.humanize_duration_minutes, new Object[]{StringResourceUtilsKt.getI18nPluralString(context, R.plurals.humanize_duration_minutes_time, i2, Integer.valueOf(i2))}, null, 4);
|
|
} else if (j <= 86400000) {
|
|
int i3 = (int) (j / 3600000);
|
|
return b.h(context, R.string.humanize_duration_hours, new Object[]{StringResourceUtilsKt.getI18nPluralString(context, R.plurals.humanize_duration_hours_time, i3, Integer.valueOf(i3))}, null, 4);
|
|
} else {
|
|
int i4 = (int) (j / 86400000);
|
|
return b.h(context, R.string.humanize_duration_days, new Object[]{StringResourceUtilsKt.getI18nPluralString(context, R.plurals.humanize_duration_days_time, i4, Integer.valueOf(i4))}, null, 4);
|
|
}
|
|
}
|
|
|
|
public static final CharSequence humanizeDurationRounded(Context context, long j) {
|
|
m.checkNotNullParameter(context, "context");
|
|
if (j <= 30000) {
|
|
String string = context.getString(R.string.humanize_duration_a_few_seconds);
|
|
m.checkNotNullExpressionValue(string, "context.getString(\n …ation_a_few_seconds\n )");
|
|
return string;
|
|
}
|
|
double d = (double) j;
|
|
if (d <= 54000.0d) {
|
|
float f = ((float) j) / ((float) 1000);
|
|
return b.h(context, R.string.humanize_duration_seconds, new Object[]{StringResourceUtilsKt.getI18nPluralString(context, R.plurals.humanize_duration_seconds_time, a.roundToInt(f), Integer.valueOf(a.roundToInt(f)))}, null, 4);
|
|
} else if (d <= 3240000.0d) {
|
|
float f2 = ((float) j) / ((float) 60000);
|
|
return b.h(context, R.string.humanize_duration_minutes, new Object[]{StringResourceUtilsKt.getI18nPluralString(context, R.plurals.humanize_duration_minutes_time, a.roundToInt(f2), Integer.valueOf(a.roundToInt(f2)))}, null, 4);
|
|
} else if (d <= 7.776E7d) {
|
|
float f3 = ((float) j) / ((float) 3600000);
|
|
return b.h(context, R.string.humanize_duration_hours, new Object[]{StringResourceUtilsKt.getI18nPluralString(context, R.plurals.humanize_duration_hours_time, a.roundToInt(f3), Integer.valueOf(a.roundToInt(f3)))}, null, 4);
|
|
} else {
|
|
float f4 = ((float) j) / ((float) 86400000);
|
|
return b.h(context, R.string.humanize_duration_days, new Object[]{StringResourceUtilsKt.getI18nPluralString(context, R.plurals.humanize_duration_days_time, a.roundToInt(f4), Integer.valueOf(a.roundToInt(f4)))}, null, 4);
|
|
}
|
|
}
|
|
}
|