mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2025-01-09 13:43:22 +00:00
210 lines
8.4 KiB
Java
210 lines
8.4 KiB
Java
package com.google.android.material.datepicker;
|
|
|
|
import android.content.res.Resources;
|
|
import android.icu.text.DateFormat;
|
|
import android.icu.text.DisplayContext;
|
|
import androidx.compose.material3.DatePickerDefaults;
|
|
import com.google.android.material.R;
|
|
import io.sentry.protocol.ViewHierarchyNode;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Calendar;
|
|
import java.util.Locale;
|
|
import java.util.TimeZone;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
/* loaded from: classes2.dex */
|
|
class UtcDates {
|
|
static final String UTC = "UTC";
|
|
static AtomicReference<TimeSource> timeSourceRef = new AtomicReference<>();
|
|
|
|
static void setTimeSource(TimeSource timeSource) {
|
|
timeSourceRef.set(timeSource);
|
|
}
|
|
|
|
static TimeSource getTimeSource() {
|
|
TimeSource timeSource = timeSourceRef.get();
|
|
return timeSource == null ? TimeSource.system() : timeSource;
|
|
}
|
|
|
|
private UtcDates() {
|
|
}
|
|
|
|
private static TimeZone getTimeZone() {
|
|
return TimeZone.getTimeZone(UTC);
|
|
}
|
|
|
|
private static android.icu.util.TimeZone getUtcAndroidTimeZone() {
|
|
return android.icu.util.TimeZone.getTimeZone(UTC);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static Calendar getTodayCalendar() {
|
|
Calendar now = getTimeSource().now();
|
|
now.set(11, 0);
|
|
now.set(12, 0);
|
|
now.set(13, 0);
|
|
now.set(14, 0);
|
|
now.setTimeZone(getTimeZone());
|
|
return now;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static Calendar getUtcCalendar() {
|
|
return getUtcCalendarOf(null);
|
|
}
|
|
|
|
static Calendar getUtcCalendarOf(Calendar calendar) {
|
|
Calendar calendar2 = Calendar.getInstance(getTimeZone());
|
|
if (calendar == null) {
|
|
calendar2.clear();
|
|
} else {
|
|
calendar2.setTimeInMillis(calendar.getTimeInMillis());
|
|
}
|
|
return calendar2;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static Calendar getDayCopy(Calendar calendar) {
|
|
Calendar utcCalendarOf = getUtcCalendarOf(calendar);
|
|
Calendar utcCalendar = getUtcCalendar();
|
|
utcCalendar.set(utcCalendarOf.get(1), utcCalendarOf.get(2), utcCalendarOf.get(5));
|
|
return utcCalendar;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static long canonicalYearMonthDay(long j) {
|
|
Calendar utcCalendar = getUtcCalendar();
|
|
utcCalendar.setTimeInMillis(j);
|
|
return getDayCopy(utcCalendar).getTimeInMillis();
|
|
}
|
|
|
|
private static DateFormat getAndroidFormat(String str, Locale locale) {
|
|
DateFormat instanceForSkeleton = DateFormat.getInstanceForSkeleton(str, locale);
|
|
instanceForSkeleton.setTimeZone(getUtcAndroidTimeZone());
|
|
instanceForSkeleton.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE);
|
|
return instanceForSkeleton;
|
|
}
|
|
|
|
private static java.text.DateFormat getFormat(int i, Locale locale) {
|
|
java.text.DateFormat dateInstance = java.text.DateFormat.getDateInstance(i, locale);
|
|
dateInstance.setTimeZone(getTimeZone());
|
|
return dateInstance;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static java.text.DateFormat getNormalizedFormat(java.text.DateFormat dateFormat) {
|
|
java.text.DateFormat dateFormat2 = (java.text.DateFormat) dateFormat.clone();
|
|
dateFormat2.setTimeZone(getTimeZone());
|
|
return dateFormat2;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static SimpleDateFormat getDefaultTextInputFormat() {
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(getDatePatternAsInputFormat(((SimpleDateFormat) java.text.DateFormat.getDateInstance(3, Locale.getDefault())).toPattern()), Locale.getDefault());
|
|
simpleDateFormat.setTimeZone(getTimeZone());
|
|
simpleDateFormat.setLenient(false);
|
|
return simpleDateFormat;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static String getDefaultTextInputHint(Resources resources, SimpleDateFormat simpleDateFormat) {
|
|
String pattern = simpleDateFormat.toPattern();
|
|
String string = resources.getString(R.string.mtrl_picker_text_input_year_abbr);
|
|
String string2 = resources.getString(R.string.mtrl_picker_text_input_month_abbr);
|
|
String string3 = resources.getString(R.string.mtrl_picker_text_input_day_abbr);
|
|
if (Locale.getDefault().getLanguage().equals(Locale.KOREAN.getLanguage())) {
|
|
pattern = pattern.replaceAll("d+", "d").replaceAll("M+", "M").replaceAll("y+", ViewHierarchyNode.JsonKeys.Y);
|
|
}
|
|
return pattern.replace("d", string3).replace("M", string2).replace(ViewHierarchyNode.JsonKeys.Y, string);
|
|
}
|
|
|
|
static String getDatePatternAsInputFormat(String str) {
|
|
return str.replaceAll("[^dMy/\\-.]", "").replaceAll("d{1,2}", "dd").replaceAll("M{1,2}", "MM").replaceAll("y{1,4}", "yyyy").replaceAll("\\.$", "").replaceAll("My", "M/y");
|
|
}
|
|
|
|
static SimpleDateFormat getSimpleFormat(String str) {
|
|
return getSimpleFormat(str, Locale.getDefault());
|
|
}
|
|
|
|
private static SimpleDateFormat getSimpleFormat(String str, Locale locale) {
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(str, locale);
|
|
simpleDateFormat.setTimeZone(getTimeZone());
|
|
return simpleDateFormat;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static DateFormat getYearMonthFormat(Locale locale) {
|
|
return getAndroidFormat(DatePickerDefaults.YearMonthSkeleton, locale);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static DateFormat getYearAbbrMonthDayFormat(Locale locale) {
|
|
return getAndroidFormat(DatePickerDefaults.YearAbbrMonthDaySkeleton, locale);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static DateFormat getAbbrMonthDayFormat(Locale locale) {
|
|
return getAndroidFormat("MMMd", locale);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static DateFormat getMonthWeekdayDayFormat(Locale locale) {
|
|
return getAndroidFormat("MMMMEEEEd", locale);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static DateFormat getYearMonthWeekdayDayFormat(Locale locale) {
|
|
return getAndroidFormat(DatePickerDefaults.YearMonthWeekdayDaySkeleton, locale);
|
|
}
|
|
|
|
static java.text.DateFormat getMediumFormat() {
|
|
return getMediumFormat(Locale.getDefault());
|
|
}
|
|
|
|
static java.text.DateFormat getMediumFormat(Locale locale) {
|
|
return getFormat(2, locale);
|
|
}
|
|
|
|
static java.text.DateFormat getMediumNoYear() {
|
|
return getMediumNoYear(Locale.getDefault());
|
|
}
|
|
|
|
static java.text.DateFormat getMediumNoYear(Locale locale) {
|
|
SimpleDateFormat simpleDateFormat = (SimpleDateFormat) getMediumFormat(locale);
|
|
simpleDateFormat.applyPattern(removeYearFromDateFormatPattern(simpleDateFormat.toPattern()));
|
|
return simpleDateFormat;
|
|
}
|
|
|
|
static java.text.DateFormat getFullFormat() {
|
|
return getFullFormat(Locale.getDefault());
|
|
}
|
|
|
|
static java.text.DateFormat getFullFormat(Locale locale) {
|
|
return getFormat(0, locale);
|
|
}
|
|
|
|
private static String removeYearFromDateFormatPattern(String str) {
|
|
int findCharactersInDateFormatPattern = findCharactersInDateFormatPattern(str, "yY", 1, 0);
|
|
if (findCharactersInDateFormatPattern >= str.length()) {
|
|
return str;
|
|
}
|
|
int findCharactersInDateFormatPattern2 = findCharactersInDateFormatPattern(str, "EMd", 1, findCharactersInDateFormatPattern);
|
|
return str.replace(str.substring(findCharactersInDateFormatPattern(str, findCharactersInDateFormatPattern2 < str.length() ? "EMd," : "EMd", -1, findCharactersInDateFormatPattern) + 1, findCharactersInDateFormatPattern2), " ").trim();
|
|
}
|
|
|
|
private static int findCharactersInDateFormatPattern(String str, String str2, int i, int i2) {
|
|
while (i2 >= 0 && i2 < str.length() && str2.indexOf(str.charAt(i2)) == -1) {
|
|
if (str.charAt(i2) != '\'') {
|
|
i2 += i;
|
|
}
|
|
do {
|
|
i2 += i;
|
|
if (i2 >= 0 && i2 < str.length()) {
|
|
}
|
|
i2 += i;
|
|
} while (str.charAt(i2) != '\'');
|
|
i2 += i;
|
|
}
|
|
return i2;
|
|
}
|
|
}
|