136 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			136 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package com.google.android.material.datepicker;
 | |
| 
 | |
| import android.os.Parcel;
 | |
| import android.os.Parcelable;
 | |
| import java.util.Arrays;
 | |
| import java.util.Calendar;
 | |
| import java.util.GregorianCalendar;
 | |
| 
 | |
| /* loaded from: classes.dex */
 | |
| final class Month implements Comparable<Month>, Parcelable {
 | |
|     public static final Parcelable.Creator<Month> CREATOR = new Parcelable.Creator<Month>() { // from class: com.google.android.material.datepicker.Month.1
 | |
|         /* JADX WARN: Can't rename method to resolve collision */
 | |
|         @Override // android.os.Parcelable.Creator
 | |
|         public Month createFromParcel(Parcel parcel) {
 | |
|             return Month.create(parcel.readInt(), parcel.readInt());
 | |
|         }
 | |
| 
 | |
|         /* JADX WARN: Can't rename method to resolve collision */
 | |
|         @Override // android.os.Parcelable.Creator
 | |
|         public Month[] newArray(int i) {
 | |
|             return new Month[i];
 | |
|         }
 | |
|     };
 | |
|     final int daysInMonth;
 | |
|     final int daysInWeek;
 | |
|     private final Calendar firstOfMonth;
 | |
|     private String longName;
 | |
|     final int month;
 | |
|     final long timeInMillis;
 | |
|     final int year;
 | |
| 
 | |
|     @Override // android.os.Parcelable
 | |
|     public int describeContents() {
 | |
|         return 0;
 | |
|     }
 | |
| 
 | |
|     private Month(Calendar calendar) {
 | |
|         calendar.set(5, 1);
 | |
|         Calendar dayCopy = UtcDates.getDayCopy(calendar);
 | |
|         this.firstOfMonth = dayCopy;
 | |
|         this.month = dayCopy.get(2);
 | |
|         this.year = dayCopy.get(1);
 | |
|         this.daysInWeek = dayCopy.getMaximum(7);
 | |
|         this.daysInMonth = dayCopy.getActualMaximum(5);
 | |
|         this.timeInMillis = dayCopy.getTimeInMillis();
 | |
|     }
 | |
| 
 | |
|     static Month create(long j) {
 | |
|         Calendar utcCalendar = UtcDates.getUtcCalendar();
 | |
|         utcCalendar.setTimeInMillis(j);
 | |
|         return new Month(utcCalendar);
 | |
|     }
 | |
| 
 | |
|     static Month create(int i, int i2) {
 | |
|         Calendar utcCalendar = UtcDates.getUtcCalendar();
 | |
|         utcCalendar.set(1, i);
 | |
|         utcCalendar.set(2, i2);
 | |
|         return new Month(utcCalendar);
 | |
|     }
 | |
| 
 | |
|     static Month current() {
 | |
|         return new Month(UtcDates.getTodayCalendar());
 | |
|     }
 | |
| 
 | |
|     int daysFromStartOfWeekToFirstOfMonth(int i) {
 | |
|         int i2 = this.firstOfMonth.get(7);
 | |
|         if (i <= 0) {
 | |
|             i = this.firstOfMonth.getFirstDayOfWeek();
 | |
|         }
 | |
|         int i3 = i2 - i;
 | |
|         return i3 < 0 ? i3 + this.daysInWeek : i3;
 | |
|     }
 | |
| 
 | |
|     public boolean equals(Object obj) {
 | |
|         if (this == obj) {
 | |
|             return true;
 | |
|         }
 | |
|         if (!(obj instanceof Month)) {
 | |
|             return false;
 | |
|         }
 | |
|         Month month = (Month) obj;
 | |
|         return this.month == month.month && this.year == month.year;
 | |
|     }
 | |
| 
 | |
|     public int hashCode() {
 | |
|         return Arrays.hashCode(new Object[]{Integer.valueOf(this.month), Integer.valueOf(this.year)});
 | |
|     }
 | |
| 
 | |
|     @Override // java.lang.Comparable
 | |
|     public int compareTo(Month month) {
 | |
|         return this.firstOfMonth.compareTo(month.firstOfMonth);
 | |
|     }
 | |
| 
 | |
|     int monthsUntil(Month month) {
 | |
|         if (this.firstOfMonth instanceof GregorianCalendar) {
 | |
|             return ((month.year - this.year) * 12) + (month.month - this.month);
 | |
|         }
 | |
|         throw new IllegalArgumentException("Only Gregorian calendars are supported.");
 | |
|     }
 | |
| 
 | |
|     long getStableId() {
 | |
|         return this.firstOfMonth.getTimeInMillis();
 | |
|     }
 | |
| 
 | |
|     long getDay(int i) {
 | |
|         Calendar dayCopy = UtcDates.getDayCopy(this.firstOfMonth);
 | |
|         dayCopy.set(5, i);
 | |
|         return dayCopy.getTimeInMillis();
 | |
|     }
 | |
| 
 | |
|     int getDayOfMonth(long j) {
 | |
|         Calendar dayCopy = UtcDates.getDayCopy(this.firstOfMonth);
 | |
|         dayCopy.setTimeInMillis(j);
 | |
|         return dayCopy.get(5);
 | |
|     }
 | |
| 
 | |
|     Month monthsLater(int i) {
 | |
|         Calendar dayCopy = UtcDates.getDayCopy(this.firstOfMonth);
 | |
|         dayCopy.add(2, i);
 | |
|         return new Month(dayCopy);
 | |
|     }
 | |
| 
 | |
|     String getLongName() {
 | |
|         if (this.longName == null) {
 | |
|             this.longName = DateStrings.getYearMonth(this.firstOfMonth.getTimeInMillis());
 | |
|         }
 | |
|         return this.longName;
 | |
|     }
 | |
| 
 | |
|     @Override // android.os.Parcelable
 | |
|     public void writeToParcel(Parcel parcel, int i) {
 | |
|         parcel.writeInt(this.year);
 | |
|         parcel.writeInt(this.month);
 | |
|     }
 | |
| }
 |