ADD week 5
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
package com.google.android.material.datepicker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.text.format.DateUtils;
|
||||
import androidx.core.util.Pair;
|
||||
import com.google.android.material.R;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class DateStrings {
|
||||
private DateStrings() {
|
||||
}
|
||||
|
||||
static String getYearMonth(long j) {
|
||||
String format;
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
format = UtcDates.getYearMonthFormat(Locale.getDefault()).format(new Date(j));
|
||||
return format;
|
||||
}
|
||||
return DateUtils.formatDateTime(null, j, 8228);
|
||||
}
|
||||
|
||||
static String getYearMonthDay(long j) {
|
||||
return getYearMonthDay(j, Locale.getDefault());
|
||||
}
|
||||
|
||||
static String getYearMonthDay(long j, Locale locale) {
|
||||
String format;
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
format = UtcDates.getYearAbbrMonthDayFormat(locale).format(new Date(j));
|
||||
return format;
|
||||
}
|
||||
return UtcDates.getMediumFormat(locale).format(new Date(j));
|
||||
}
|
||||
|
||||
static String getMonthDay(long j) {
|
||||
return getMonthDay(j, Locale.getDefault());
|
||||
}
|
||||
|
||||
static String getMonthDay(long j, Locale locale) {
|
||||
String format;
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
format = UtcDates.getAbbrMonthDayFormat(locale).format(new Date(j));
|
||||
return format;
|
||||
}
|
||||
return UtcDates.getMediumNoYear(locale).format(new Date(j));
|
||||
}
|
||||
|
||||
static String getMonthDayOfWeekDay(long j) {
|
||||
return getMonthDayOfWeekDay(j, Locale.getDefault());
|
||||
}
|
||||
|
||||
static String getMonthDayOfWeekDay(long j, Locale locale) {
|
||||
String format;
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
format = UtcDates.getMonthWeekdayDayFormat(locale).format(new Date(j));
|
||||
return format;
|
||||
}
|
||||
return UtcDates.getFullFormat(locale).format(new Date(j));
|
||||
}
|
||||
|
||||
static String getYearMonthDayOfWeekDay(long j) {
|
||||
return getYearMonthDayOfWeekDay(j, Locale.getDefault());
|
||||
}
|
||||
|
||||
static String getYearMonthDayOfWeekDay(long j, Locale locale) {
|
||||
String format;
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
format = UtcDates.getYearMonthWeekdayDayFormat(locale).format(new Date(j));
|
||||
return format;
|
||||
}
|
||||
return UtcDates.getFullFormat(locale).format(new Date(j));
|
||||
}
|
||||
|
||||
static String getOptionalYearMonthDayOfWeekDay(long j) {
|
||||
if (isDateWithinCurrentYear(j)) {
|
||||
return getMonthDayOfWeekDay(j);
|
||||
}
|
||||
return getYearMonthDayOfWeekDay(j);
|
||||
}
|
||||
|
||||
static String getDateString(long j) {
|
||||
return getDateString(j, null);
|
||||
}
|
||||
|
||||
static String getDateString(long j, SimpleDateFormat simpleDateFormat) {
|
||||
if (simpleDateFormat != null) {
|
||||
return simpleDateFormat.format(new Date(j));
|
||||
}
|
||||
if (isDateWithinCurrentYear(j)) {
|
||||
return getMonthDay(j);
|
||||
}
|
||||
return getYearMonthDay(j);
|
||||
}
|
||||
|
||||
private static boolean isDateWithinCurrentYear(long j) {
|
||||
Calendar todayCalendar = UtcDates.getTodayCalendar();
|
||||
Calendar utcCalendar = UtcDates.getUtcCalendar();
|
||||
utcCalendar.setTimeInMillis(j);
|
||||
return todayCalendar.get(1) == utcCalendar.get(1);
|
||||
}
|
||||
|
||||
static Pair<String, String> getDateRangeString(Long l, Long l2) {
|
||||
return getDateRangeString(l, l2, null);
|
||||
}
|
||||
|
||||
static Pair<String, String> getDateRangeString(Long l, Long l2, SimpleDateFormat simpleDateFormat) {
|
||||
if (l == null && l2 == null) {
|
||||
return Pair.create(null, null);
|
||||
}
|
||||
if (l == null) {
|
||||
return Pair.create(null, getDateString(l2.longValue(), simpleDateFormat));
|
||||
}
|
||||
if (l2 == null) {
|
||||
return Pair.create(getDateString(l.longValue(), simpleDateFormat), null);
|
||||
}
|
||||
Calendar todayCalendar = UtcDates.getTodayCalendar();
|
||||
Calendar utcCalendar = UtcDates.getUtcCalendar();
|
||||
utcCalendar.setTimeInMillis(l.longValue());
|
||||
Calendar utcCalendar2 = UtcDates.getUtcCalendar();
|
||||
utcCalendar2.setTimeInMillis(l2.longValue());
|
||||
if (simpleDateFormat != null) {
|
||||
return Pair.create(simpleDateFormat.format(new Date(l.longValue())), simpleDateFormat.format(new Date(l2.longValue())));
|
||||
}
|
||||
if (utcCalendar.get(1) == utcCalendar2.get(1)) {
|
||||
if (utcCalendar.get(1) == todayCalendar.get(1)) {
|
||||
return Pair.create(getMonthDay(l.longValue(), Locale.getDefault()), getMonthDay(l2.longValue(), Locale.getDefault()));
|
||||
}
|
||||
return Pair.create(getMonthDay(l.longValue(), Locale.getDefault()), getYearMonthDay(l2.longValue(), Locale.getDefault()));
|
||||
}
|
||||
return Pair.create(getYearMonthDay(l.longValue(), Locale.getDefault()), getYearMonthDay(l2.longValue(), Locale.getDefault()));
|
||||
}
|
||||
|
||||
static String getDayContentDescription(Context context, long j, boolean z, boolean z2, boolean z3) {
|
||||
String optionalYearMonthDayOfWeekDay = getOptionalYearMonthDayOfWeekDay(j);
|
||||
if (z) {
|
||||
optionalYearMonthDayOfWeekDay = String.format(context.getString(R.string.mtrl_picker_today_description), optionalYearMonthDayOfWeekDay);
|
||||
}
|
||||
if (z2) {
|
||||
return String.format(context.getString(R.string.mtrl_picker_start_date_description), optionalYearMonthDayOfWeekDay);
|
||||
}
|
||||
return z3 ? String.format(context.getString(R.string.mtrl_picker_end_date_description), optionalYearMonthDayOfWeekDay) : optionalYearMonthDayOfWeekDay;
|
||||
}
|
||||
|
||||
static String getYearContentDescription(Context context, int i) {
|
||||
if (UtcDates.getTodayCalendar().get(1) == i) {
|
||||
return String.format(context.getString(R.string.mtrl_picker_navigate_to_current_year_description), Integer.valueOf(i));
|
||||
}
|
||||
return String.format(context.getString(R.string.mtrl_picker_navigate_to_year_description), Integer.valueOf(i));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user