discord-jadx/app/src/main/java/b/g/a/c/i0/r.java

425 lines
15 KiB
Java
Raw Normal View History

2021-12-21 23:37:30 +00:00
package b.g.a.c.i0;
2021-06-27 20:44:35 +00:00
import androidx.core.app.NotificationManagerCompat;
2021-12-21 23:37:30 +00:00
import b.g.a.b.p.f;
import com.discord.utilities.time.TimeUtils;
import com.discord.widgets.chat.input.MentionUtilsKt;
2021-06-27 20:44:35 +00:00
import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
2022-03-02 20:59:20 +00:00
/* compiled from: StdDateFormat.java */
2022-03-08 21:11:21 +00:00
/* loaded from: classes3.dex */
2021-06-27 20:44:35 +00:00
public class r extends DateFormat {
2021-12-17 22:03:14 +00:00
public static final Pattern j = Pattern.compile("\\d\\d\\d\\d[-]\\d\\d[-]\\d\\d");
2022-03-02 20:59:20 +00:00
public static final Pattern k;
public static final String[] l;
2021-12-17 22:03:14 +00:00
public static final TimeZone m;
public static final Locale n;
public static final DateFormat o;
2022-03-02 20:59:20 +00:00
public static final r p;
2021-12-17 22:03:14 +00:00
public static final Calendar q;
2021-06-27 20:44:35 +00:00
public Boolean _lenient;
public final Locale _locale;
private boolean _tzSerializedWithColon;
2021-12-17 22:03:14 +00:00
public transient TimeZone r;
2021-06-27 20:44:35 +00:00
2021-11-08 18:25:28 +00:00
/* renamed from: s reason: collision with root package name */
2022-02-14 21:43:51 +00:00
public transient Calendar f726s;
2021-12-17 22:03:14 +00:00
public transient DateFormat t;
2021-06-27 20:44:35 +00:00
static {
try {
2022-03-02 20:59:20 +00:00
k = Pattern.compile("\\d\\d\\d\\d[-]\\d\\d[-]\\d\\d[T]\\d\\d[:]\\d\\d(?:[:]\\d\\d)?(\\.\\d+)?(Z|[+-]\\d\\d(?:[:]?\\d\\d)?)?");
l = new String[]{"yyyy-MM-dd'T'HH:mm:ss.SSSX", "yyyy-MM-dd'T'HH:mm:ss.SSS", "EEE, dd MMM yyyy HH:mm:ss zzz", TimeUtils.UTCFormat.SHORT};
2021-06-27 20:44:35 +00:00
TimeZone timeZone = TimeZone.getTimeZone("UTC");
2021-12-17 22:03:14 +00:00
m = timeZone;
2021-06-27 20:44:35 +00:00
Locale locale = Locale.US;
2021-12-17 22:03:14 +00:00
n = locale;
2021-06-27 20:44:35 +00:00
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", locale);
2021-12-17 22:03:14 +00:00
o = simpleDateFormat;
2021-06-27 20:44:35 +00:00
simpleDateFormat.setTimeZone(timeZone);
2022-03-02 20:59:20 +00:00
p = new r();
2021-12-17 22:03:14 +00:00
q = new GregorianCalendar(timeZone, locale);
2021-06-27 20:44:35 +00:00
} catch (Throwable th) {
throw new RuntimeException(th);
}
}
public r() {
this._tzSerializedWithColon = true;
2021-12-17 22:03:14 +00:00
this._locale = n;
2021-06-27 20:44:35 +00:00
}
public r(TimeZone timeZone, Locale locale, Boolean bool, boolean z2) {
this._tzSerializedWithColon = true;
2021-12-17 22:03:14 +00:00
this.r = timeZone;
2021-06-27 20:44:35 +00:00
this._locale = locale;
this._lenient = bool;
this._tzSerializedWithColon = z2;
}
2021-12-17 22:03:14 +00:00
public static int f(String str, int i) {
return (str.charAt(i + 1) - '0') + ((str.charAt(i) - '0') * 10);
2021-06-27 20:44:35 +00:00
}
2021-12-17 22:03:14 +00:00
public static int g(String str, int i) {
int charAt = ((str.charAt(i + 1) - '0') * 100) + ((str.charAt(i) - '0') * 1000);
return (str.charAt(i + 3) - '0') + ((str.charAt(i + 2) - '0') * 10) + charAt;
2021-06-27 20:44:35 +00:00
}
2021-12-17 22:03:14 +00:00
public static void j(StringBuffer stringBuffer, int i) {
int i2 = i / 10;
if (i2 == 0) {
2021-06-27 20:44:35 +00:00
stringBuffer.append('0');
} else {
2021-12-17 22:03:14 +00:00
stringBuffer.append((char) (i2 + 48));
i -= i2 * 10;
2021-06-27 20:44:35 +00:00
}
2021-12-17 22:03:14 +00:00
stringBuffer.append((char) (i + 48));
2021-06-27 20:44:35 +00:00
}
2021-12-17 22:03:14 +00:00
public static void k(StringBuffer stringBuffer, int i) {
int i2 = i / 100;
if (i2 == 0) {
2021-06-27 20:44:35 +00:00
stringBuffer.append('0');
stringBuffer.append('0');
} else {
2021-12-17 22:03:14 +00:00
if (i2 > 99) {
stringBuffer.append(i2);
2021-06-27 20:44:35 +00:00
} else {
2021-12-17 22:03:14 +00:00
j(stringBuffer, i2);
2021-06-27 20:44:35 +00:00
}
2021-12-17 22:03:14 +00:00
i -= i2 * 100;
2021-06-27 20:44:35 +00:00
}
2021-12-17 22:03:14 +00:00
j(stringBuffer, i);
2021-06-27 20:44:35 +00:00
}
public Calendar b(TimeZone timeZone) {
2022-02-14 21:43:51 +00:00
Calendar calendar = this.f726s;
2021-06-27 20:44:35 +00:00
if (calendar == null) {
2021-12-17 22:03:14 +00:00
calendar = (Calendar) q.clone();
2022-02-14 21:43:51 +00:00
this.f726s = calendar;
2021-06-27 20:44:35 +00:00
}
if (!calendar.getTimeZone().equals(timeZone)) {
calendar.setTimeZone(timeZone);
}
calendar.setLenient(isLenient());
return calendar;
}
2022-03-02 20:59:20 +00:00
@Override // java.text.DateFormat, java.text.Format
2021-06-27 20:44:35 +00:00
public Object clone() {
2021-12-17 22:03:14 +00:00
return new r(this.r, this._locale, this._lenient, this._tzSerializedWithColon);
2021-06-27 20:44:35 +00:00
}
2022-03-02 20:59:20 +00:00
@Override // java.text.DateFormat
2021-06-27 20:44:35 +00:00
public boolean equals(Object obj) {
return obj == this;
}
@Override // java.text.DateFormat
public StringBuffer format(Date date, StringBuffer stringBuffer, FieldPosition fieldPosition) {
2021-12-17 22:03:14 +00:00
TimeZone timeZone = this.r;
2021-06-27 20:44:35 +00:00
if (timeZone == null) {
2021-12-17 22:03:14 +00:00
timeZone = m;
2021-06-27 20:44:35 +00:00
}
2021-12-21 23:37:30 +00:00
Calendar b2 = b(timeZone);
b2.setTime(date);
int i = b2.get(1);
char c = '+';
if (b2.get(0) != 0) {
2021-12-17 22:03:14 +00:00
if (i > 9999) {
2021-06-27 20:44:35 +00:00
stringBuffer.append('+');
}
2021-12-17 22:03:14 +00:00
k(stringBuffer, i);
} else if (i == 1) {
2021-06-27 20:44:35 +00:00
stringBuffer.append("+0000");
} else {
stringBuffer.append('-');
2021-12-17 22:03:14 +00:00
k(stringBuffer, i - 1);
2021-06-27 20:44:35 +00:00
}
stringBuffer.append('-');
2021-12-21 23:37:30 +00:00
j(stringBuffer, b2.get(2) + 1);
2021-06-27 20:44:35 +00:00
stringBuffer.append('-');
2021-12-21 23:37:30 +00:00
j(stringBuffer, b2.get(5));
2021-06-27 20:44:35 +00:00
stringBuffer.append('T');
2021-12-21 23:37:30 +00:00
j(stringBuffer, b2.get(11));
stringBuffer.append(MentionUtilsKt.EMOJIS_AND_STICKERS_CHAR);
2021-12-21 23:37:30 +00:00
j(stringBuffer, b2.get(12));
stringBuffer.append(MentionUtilsKt.EMOJIS_AND_STICKERS_CHAR);
2021-12-21 23:37:30 +00:00
j(stringBuffer, b2.get(13));
2021-06-27 20:44:35 +00:00
stringBuffer.append('.');
2021-12-21 23:37:30 +00:00
int i2 = b2.get(14);
2021-12-17 22:03:14 +00:00
int i3 = i2 / 100;
if (i3 == 0) {
2021-06-27 20:44:35 +00:00
stringBuffer.append('0');
} else {
2021-12-17 22:03:14 +00:00
stringBuffer.append((char) (i3 + 48));
i2 -= i3 * 100;
2021-06-27 20:44:35 +00:00
}
2021-12-17 22:03:14 +00:00
j(stringBuffer, i2);
2021-12-21 23:37:30 +00:00
int offset = timeZone.getOffset(b2.getTimeInMillis());
2021-06-27 20:44:35 +00:00
if (offset != 0) {
2021-12-17 22:03:14 +00:00
int i4 = offset / 60000;
int abs = Math.abs(i4 / 60);
int abs2 = Math.abs(i4 % 60);
2021-06-27 20:44:35 +00:00
if (offset < 0) {
2021-12-21 23:37:30 +00:00
c = '-';
2021-06-27 20:44:35 +00:00
}
2021-12-21 23:37:30 +00:00
stringBuffer.append(c);
2021-06-27 20:44:35 +00:00
j(stringBuffer, abs);
if (this._tzSerializedWithColon) {
stringBuffer.append(MentionUtilsKt.EMOJIS_AND_STICKERS_CHAR);
2021-06-27 20:44:35 +00:00
}
j(stringBuffer, abs2);
} else if (this._tzSerializedWithColon) {
stringBuffer.append("+00:00");
} else {
stringBuffer.append("+0000");
}
return stringBuffer;
}
@Override // java.text.DateFormat
public TimeZone getTimeZone() {
2021-12-17 22:03:14 +00:00
return this.r;
2021-06-27 20:44:35 +00:00
}
public Date h(String str) throws IllegalArgumentException, ParseException {
2021-12-21 23:37:30 +00:00
char c;
2021-06-27 20:44:35 +00:00
String str2;
int length = str.length();
2021-12-17 22:03:14 +00:00
TimeZone timeZone = m;
if (!(this.r == null || 'Z' == str.charAt(length - 1))) {
timeZone = this.r;
2021-06-27 20:44:35 +00:00
}
2021-12-21 23:37:30 +00:00
Calendar b2 = b(timeZone);
b2.clear();
2021-12-17 22:03:14 +00:00
int i = 0;
2021-06-27 20:44:35 +00:00
if (length > 10) {
2021-12-17 22:03:14 +00:00
Matcher matcher = k.matcher(str);
2021-06-27 20:44:35 +00:00
if (matcher.matches()) {
int start = matcher.start(2);
int end = matcher.end(2);
2021-12-17 22:03:14 +00:00
int i2 = end - start;
if (i2 > 1) {
2021-06-27 20:44:35 +00:00
int f = f(str, start + 1) * 3600;
2021-12-17 22:03:14 +00:00
if (i2 >= 5) {
2021-06-27 20:44:35 +00:00
f += f(str, end - 2) * 60;
}
2021-12-21 23:37:30 +00:00
b2.set(15, str.charAt(start) == '-' ? f * NotificationManagerCompat.IMPORTANCE_UNSPECIFIED : f * 1000);
b2.set(16, 0);
2021-06-27 20:44:35 +00:00
}
2021-12-21 23:37:30 +00:00
b2.set(g(str, 0), f(str, 5) - 1, f(str, 8), f(str, 11), f(str, 14), (length <= 16 || str.charAt(16) != ':') ? 0 : f(str, 17));
2021-06-27 20:44:35 +00:00
int start2 = matcher.start(1) + 1;
int end2 = matcher.end(1);
if (start2 >= end2) {
2021-12-21 23:37:30 +00:00
b2.set(14, 0);
2021-06-27 20:44:35 +00:00
} else {
2021-12-17 22:03:14 +00:00
int i3 = end2 - start2;
if (i3 != 0) {
if (i3 != 1) {
if (i3 != 2) {
if (i3 == 3 || i3 <= 9) {
i = 0 + (str.charAt(start2 + 2) - '0');
2021-06-27 20:44:35 +00:00
} else {
throw new ParseException(String.format("Cannot parse date \"%s\": invalid fractional seconds '%s'; can use at most 9 digits", str, matcher.group(1).substring(1)), start2);
}
}
2021-12-17 22:03:14 +00:00
i += (str.charAt(start2 + 1) - '0') * 10;
2021-06-27 20:44:35 +00:00
}
2021-12-17 22:03:14 +00:00
i += (str.charAt(start2) - '0') * 100;
2021-06-27 20:44:35 +00:00
}
2021-12-21 23:37:30 +00:00
b2.set(14, i);
2021-06-27 20:44:35 +00:00
}
2021-12-21 23:37:30 +00:00
return b2.getTime();
2021-06-27 20:44:35 +00:00
}
2021-12-21 23:37:30 +00:00
c = 1;
2021-06-27 20:44:35 +00:00
str2 = "yyyy-MM-dd'T'HH:mm:ss.SSSX";
2021-12-17 22:03:14 +00:00
} else if (j.matcher(str).matches()) {
2021-12-21 23:37:30 +00:00
b2.set(g(str, 0), f(str, 5) - 1, f(str, 8), 0, 0, 0);
b2.set(14, 0);
return b2.getTime();
2021-06-27 20:44:35 +00:00
} else {
str2 = TimeUtils.UTCFormat.SHORT;
2021-12-21 23:37:30 +00:00
c = 1;
2021-06-27 20:44:35 +00:00
}
Object[] objArr = new Object[3];
objArr[0] = str;
2021-12-21 23:37:30 +00:00
objArr[c] = str2;
2021-06-27 20:44:35 +00:00
objArr[2] = this._lenient;
throw new ParseException(String.format("Cannot parse date \"%s\": while it seems to fit format '%s', parsing fails (leniency? %s)", objArr), 0);
}
2022-03-02 20:59:20 +00:00
@Override // java.text.DateFormat
2021-06-27 20:44:35 +00:00
public int hashCode() {
return System.identityHashCode(this);
}
2022-03-02 20:59:20 +00:00
/* JADX WARN: Code restructure failed: missing block: B:39:0x0096, code lost:
2021-06-27 20:44:35 +00:00
if (r5 < 0) goto L_0x0098;
*/
2022-03-02 20:59:20 +00:00
/* JADX WARN: Code restructure failed: missing block: B:43:0x009f, code lost:
2021-06-27 20:44:35 +00:00
if (r0 == false) goto L_0x00bf;
*/
2022-03-02 20:59:20 +00:00
/*
Code decompiled incorrectly, please refer to instructions dump.
*/
2021-06-27 20:44:35 +00:00
public Date i(String str, ParsePosition parsePosition) throws ParseException {
DateFormat dateFormat;
boolean z2;
if (str.length() >= 7 && Character.isDigit(str.charAt(0)) && Character.isDigit(str.charAt(3)) && str.charAt(4) == '-' && Character.isDigit(str.charAt(5))) {
try {
return h(str);
} catch (IllegalArgumentException e) {
throw new ParseException(String.format("Cannot parse date \"%s\", problem: %s", str, e.getMessage()), parsePosition.getErrorIndex());
}
} else {
int length = str.length();
while (true) {
length--;
if (length < 0) {
break;
}
char charAt = str.charAt(length);
if (charAt < '0' || charAt > '9') {
if (length > 0 || charAt != '-') {
break;
}
}
}
if (length < 0) {
if (str.charAt(0) != '-') {
2022-02-14 21:43:51 +00:00
String str2 = f.f665b;
2021-06-27 20:44:35 +00:00
int length2 = str2.length();
int length3 = str.length();
if (length3 >= length2) {
if (length3 <= length2) {
2021-12-17 22:03:14 +00:00
int i = 0;
2021-06-27 20:44:35 +00:00
while (true) {
2021-12-17 22:03:14 +00:00
if (i >= length2) {
2021-06-27 20:44:35 +00:00
break;
}
2021-12-17 22:03:14 +00:00
int charAt2 = str.charAt(i) - str2.charAt(i);
2021-06-27 20:44:35 +00:00
if (charAt2 == 0) {
2021-12-17 22:03:14 +00:00
i++;
2021-06-27 20:44:35 +00:00
}
}
}
z2 = false;
}
z2 = true;
}
try {
return new Date(f.a(str));
} catch (NumberFormatException unused) {
throw new ParseException(String.format("Timestamp value %s out of 64-bit value range", str), parsePosition.getErrorIndex());
}
}
2021-12-17 22:03:14 +00:00
if (this.t == null) {
DateFormat dateFormat2 = o;
TimeZone timeZone = this.r;
2021-06-27 20:44:35 +00:00
Locale locale = this._locale;
Boolean bool = this._lenient;
2021-12-17 22:03:14 +00:00
if (!locale.equals(n)) {
2021-06-27 20:44:35 +00:00
dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", locale);
if (timeZone == null) {
2021-12-17 22:03:14 +00:00
timeZone = m;
2021-06-27 20:44:35 +00:00
}
dateFormat.setTimeZone(timeZone);
} else {
dateFormat = (DateFormat) dateFormat2.clone();
if (timeZone != null) {
dateFormat.setTimeZone(timeZone);
}
}
if (bool != null) {
dateFormat.setLenient(bool.booleanValue());
}
2021-12-17 22:03:14 +00:00
this.t = dateFormat;
2021-06-27 20:44:35 +00:00
}
2021-12-17 22:03:14 +00:00
return this.t.parse(str, parsePosition);
2021-06-27 20:44:35 +00:00
}
}
@Override // java.text.DateFormat
public boolean isLenient() {
Boolean bool = this._lenient;
return bool == null || bool.booleanValue();
}
public r l(Locale locale) {
2021-12-17 22:03:14 +00:00
return locale.equals(this._locale) ? this : new r(this.r, locale, this._lenient, this._tzSerializedWithColon);
2021-06-27 20:44:35 +00:00
}
public r m(TimeZone timeZone) {
if (timeZone == null) {
2021-12-17 22:03:14 +00:00
timeZone = m;
2021-06-27 20:44:35 +00:00
}
2021-12-17 22:03:14 +00:00
TimeZone timeZone2 = this.r;
2021-06-27 20:44:35 +00:00
return (timeZone == timeZone2 || timeZone.equals(timeZone2)) ? this : new r(timeZone, this._locale, this._lenient, this._tzSerializedWithColon);
}
@Override // java.text.DateFormat
public Date parse(String str) throws ParseException {
2022-03-02 20:59:20 +00:00
String[] strArr;
2021-06-27 20:44:35 +00:00
String trim = str.trim();
ParsePosition parsePosition = new ParsePosition(0);
2021-12-17 22:03:14 +00:00
Date i = i(trim, parsePosition);
if (i != null) {
return i;
2021-06-27 20:44:35 +00:00
}
StringBuilder sb = new StringBuilder();
2022-03-02 20:59:20 +00:00
for (String str2 : l) {
2021-06-27 20:44:35 +00:00
if (sb.length() > 0) {
sb.append("\", \"");
} else {
sb.append('\"');
}
sb.append(str2);
}
sb.append('\"');
throw new ParseException(String.format("Cannot parse date \"%s\": not compatible with any of standard forms (%s)", trim, sb.toString()), parsePosition.getErrorIndex());
}
@Override // java.text.DateFormat
public Date parse(String str, ParsePosition parsePosition) {
try {
return i(str, parsePosition);
} catch (ParseException unused) {
return null;
}
}
@Override // java.text.DateFormat
public void setLenient(boolean z2) {
Boolean valueOf = Boolean.valueOf(z2);
Boolean bool = this._lenient;
if (!(valueOf == bool || (valueOf != null && valueOf.equals(bool)))) {
this._lenient = valueOf;
2021-12-17 22:03:14 +00:00
this.t = null;
2021-06-27 20:44:35 +00:00
}
}
@Override // java.text.DateFormat
public void setTimeZone(TimeZone timeZone) {
2021-12-17 22:03:14 +00:00
if (!timeZone.equals(this.r)) {
this.t = null;
this.r = timeZone;
2021-06-27 20:44:35 +00:00
}
}
public String toString() {
2021-12-17 22:03:14 +00:00
return String.format("DateFormat %s: (timezone: %s, locale: %s, lenient: %s)", r.class.getName(), this.r, this._locale, this._lenient);
2021-06-27 20:44:35 +00:00
}
}