158 lines
4.5 KiB
Java
158 lines
4.5 KiB
Java
package com.google.zxing.client.result;
|
|
|
|
import java.text.DateFormat;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
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;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class CalendarParsedResult extends ParsedResult {
|
|
private static final Pattern k = Pattern.compile("P(?:(\\d+)W)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?)?");
|
|
private static final long[] l = {604800000, 86400000, 3600000, 60000, 1000};
|
|
private static final Pattern m = Pattern.compile("[0-9]{8}(T[0-9]{6}Z?)?");
|
|
private final String b;
|
|
private final long c;
|
|
private final boolean d;
|
|
private final long e;
|
|
private final boolean f;
|
|
private final String g;
|
|
private final String h;
|
|
private final String[] i;
|
|
private final String j;
|
|
|
|
public CalendarParsedResult(String str, String str2, String str3, String str4, String str5, String str6, String[] strArr, String str7, double d, double d2) {
|
|
super(ParsedResultType.CALENDAR);
|
|
this.b = str;
|
|
try {
|
|
this.c = a(str2);
|
|
if (str3 == null) {
|
|
long a = a((CharSequence) str4);
|
|
this.e = a < 0 ? -1L : a + this.c;
|
|
} else {
|
|
try {
|
|
this.e = a(str3);
|
|
} catch (ParseException e) {
|
|
throw new IllegalArgumentException(e.toString());
|
|
}
|
|
}
|
|
this.d = str2.length() == 8;
|
|
this.f = str3 != null && str3.length() == 8;
|
|
this.g = str5;
|
|
this.h = str6;
|
|
this.i = strArr;
|
|
this.j = str7;
|
|
} catch (ParseException e2) {
|
|
throw new IllegalArgumentException(e2.toString());
|
|
}
|
|
}
|
|
|
|
private static long b(String str) throws ParseException {
|
|
return new SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.ENGLISH).parse(str).getTime();
|
|
}
|
|
|
|
@Override // com.google.zxing.client.result.ParsedResult
|
|
public String a() {
|
|
StringBuilder sb = new StringBuilder(100);
|
|
ParsedResult.a(this.b, sb);
|
|
ParsedResult.a(a(this.d, this.c), sb);
|
|
ParsedResult.a(a(this.f, this.e), sb);
|
|
ParsedResult.a(this.g, sb);
|
|
ParsedResult.a(this.h, sb);
|
|
ParsedResult.a(this.i, sb);
|
|
ParsedResult.a(this.j, sb);
|
|
return sb.toString();
|
|
}
|
|
|
|
public String[] c() {
|
|
return this.i;
|
|
}
|
|
|
|
public String d() {
|
|
return this.j;
|
|
}
|
|
|
|
public long e() {
|
|
return this.e;
|
|
}
|
|
|
|
public String f() {
|
|
return this.g;
|
|
}
|
|
|
|
public String g() {
|
|
return this.h;
|
|
}
|
|
|
|
public long h() {
|
|
return this.c;
|
|
}
|
|
|
|
public String i() {
|
|
return this.b;
|
|
}
|
|
|
|
public boolean j() {
|
|
return this.f;
|
|
}
|
|
|
|
public boolean k() {
|
|
return this.d;
|
|
}
|
|
|
|
private static long a(String str) throws ParseException {
|
|
if (m.matcher(str).matches()) {
|
|
if (str.length() == 8) {
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd", Locale.ENGLISH);
|
|
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
|
return simpleDateFormat.parse(str).getTime();
|
|
}
|
|
if (str.length() == 16 && str.charAt(15) == 'Z') {
|
|
long b = b(str.substring(0, 15));
|
|
long j = b + r5.get(15);
|
|
new GregorianCalendar().setTime(new Date(j));
|
|
return j + r5.get(16);
|
|
}
|
|
return b(str);
|
|
}
|
|
throw new ParseException(str, 0);
|
|
}
|
|
|
|
private static String a(boolean z, long j) {
|
|
DateFormat dateTimeInstance;
|
|
if (j < 0) {
|
|
return null;
|
|
}
|
|
if (z) {
|
|
dateTimeInstance = DateFormat.getDateInstance(2);
|
|
} else {
|
|
dateTimeInstance = DateFormat.getDateTimeInstance(2, 2);
|
|
}
|
|
return dateTimeInstance.format(Long.valueOf(j));
|
|
}
|
|
|
|
private static long a(CharSequence charSequence) {
|
|
if (charSequence == null) {
|
|
return -1L;
|
|
}
|
|
Matcher matcher = k.matcher(charSequence);
|
|
if (!matcher.matches()) {
|
|
return -1L;
|
|
}
|
|
long j = 0;
|
|
int i = 0;
|
|
while (i < l.length) {
|
|
int i2 = i + 1;
|
|
if (matcher.group(i2) != null) {
|
|
j += l[i] * Integer.parseInt(r4);
|
|
}
|
|
i = i2;
|
|
}
|
|
return j;
|
|
}
|
|
}
|