237 lines
7.1 KiB
C#
237 lines
7.1 KiB
C#
using System;
|
|
|
|
namespace System.Globalization
|
|
{
|
|
// Token: 0x0200016C RID: 364
|
|
internal class CCGregorianCalendar
|
|
{
|
|
// Token: 0x060011CA RID: 4554 RVA: 0x000462D8 File Offset: 0x000444D8
|
|
public static bool is_leap_year(int year)
|
|
{
|
|
if (CCMath.mod(year, 4) != 0)
|
|
{
|
|
return false;
|
|
}
|
|
int num = CCMath.mod(year, 400);
|
|
return num != 100 && num != 200 && num != 300;
|
|
}
|
|
|
|
// Token: 0x060011CB RID: 4555 RVA: 0x0004632C File Offset: 0x0004452C
|
|
public static int fixed_from_dmy(int day, int month, int year)
|
|
{
|
|
int num = 0;
|
|
num += 365 * (year - 1);
|
|
num += CCMath.div(year - 1, 4);
|
|
num -= CCMath.div(year - 1, 100);
|
|
num += CCMath.div(year - 1, 400);
|
|
num += CCMath.div(367 * month - 362, 12);
|
|
if (month > 2)
|
|
{
|
|
num += ((!CCGregorianCalendar.is_leap_year(year)) ? (-2) : (-1));
|
|
}
|
|
return num + day;
|
|
}
|
|
|
|
// Token: 0x060011CC RID: 4556 RVA: 0x000463AC File Offset: 0x000445AC
|
|
public static int year_from_fixed(int date)
|
|
{
|
|
int num = date - 1;
|
|
int num2 = CCMath.div_mod(out num, num, 146097);
|
|
int num3 = CCMath.div_mod(out num, num, 36524);
|
|
int num4 = CCMath.div_mod(out num, num, 1461);
|
|
int num5 = CCMath.div(num, 365);
|
|
int num6 = 400 * num2 + 100 * num3 + 4 * num4 + num5;
|
|
return (num3 != 4 && num5 != 4) ? (num6 + 1) : num6;
|
|
}
|
|
|
|
// Token: 0x060011CD RID: 4557 RVA: 0x00046424 File Offset: 0x00044624
|
|
public static void my_from_fixed(out int month, out int year, int date)
|
|
{
|
|
year = CCGregorianCalendar.year_from_fixed(date);
|
|
int num = date - CCGregorianCalendar.fixed_from_dmy(1, 1, year);
|
|
int num2;
|
|
if (date < CCGregorianCalendar.fixed_from_dmy(1, 3, year))
|
|
{
|
|
num2 = 0;
|
|
}
|
|
else if (CCGregorianCalendar.is_leap_year(year))
|
|
{
|
|
num2 = 1;
|
|
}
|
|
else
|
|
{
|
|
num2 = 2;
|
|
}
|
|
month = CCMath.div(12 * (num + num2) + 373, 367);
|
|
}
|
|
|
|
// Token: 0x060011CE RID: 4558 RVA: 0x00046488 File Offset: 0x00044688
|
|
public static void dmy_from_fixed(out int day, out int month, out int year, int date)
|
|
{
|
|
CCGregorianCalendar.my_from_fixed(out month, out year, date);
|
|
day = date - CCGregorianCalendar.fixed_from_dmy(1, month, year) + 1;
|
|
}
|
|
|
|
// Token: 0x060011CF RID: 4559 RVA: 0x000464A4 File Offset: 0x000446A4
|
|
public static int month_from_fixed(int date)
|
|
{
|
|
int num;
|
|
int num2;
|
|
CCGregorianCalendar.my_from_fixed(out num, out num2, date);
|
|
return num;
|
|
}
|
|
|
|
// Token: 0x060011D0 RID: 4560 RVA: 0x000464BC File Offset: 0x000446BC
|
|
public static int day_from_fixed(int date)
|
|
{
|
|
int num;
|
|
int num2;
|
|
int num3;
|
|
CCGregorianCalendar.dmy_from_fixed(out num, out num2, out num3, date);
|
|
return num;
|
|
}
|
|
|
|
// Token: 0x060011D1 RID: 4561 RVA: 0x000464D8 File Offset: 0x000446D8
|
|
public static int date_difference(int dayA, int monthA, int yearA, int dayB, int monthB, int yearB)
|
|
{
|
|
return CCGregorianCalendar.fixed_from_dmy(dayB, monthB, yearB) - CCGregorianCalendar.fixed_from_dmy(dayA, monthA, yearA);
|
|
}
|
|
|
|
// Token: 0x060011D2 RID: 4562 RVA: 0x000464F0 File Offset: 0x000446F0
|
|
public static int day_number(int day, int month, int year)
|
|
{
|
|
return CCGregorianCalendar.date_difference(31, 12, year - 1, day, month, year);
|
|
}
|
|
|
|
// Token: 0x060011D3 RID: 4563 RVA: 0x00046504 File Offset: 0x00044704
|
|
public static int days_remaining(int day, int month, int year)
|
|
{
|
|
return CCGregorianCalendar.date_difference(day, month, year, 31, 12, year);
|
|
}
|
|
|
|
// Token: 0x060011D4 RID: 4564 RVA: 0x00046514 File Offset: 0x00044714
|
|
public static DateTime AddMonths(DateTime time, int months)
|
|
{
|
|
int num = CCFixed.FromDateTime(time);
|
|
int num2;
|
|
int num3;
|
|
int num4;
|
|
CCGregorianCalendar.dmy_from_fixed(out num2, out num3, out num4, num);
|
|
num3 += months;
|
|
num4 += CCMath.div_mod(out num3, num3, 12);
|
|
int daysInMonth = CCGregorianCalendar.GetDaysInMonth(num4, num3);
|
|
if (num2 > daysInMonth)
|
|
{
|
|
num2 = daysInMonth;
|
|
}
|
|
num = CCGregorianCalendar.fixed_from_dmy(num2, num3, num4);
|
|
return CCFixed.ToDateTime(num).Add(time.TimeOfDay);
|
|
}
|
|
|
|
// Token: 0x060011D5 RID: 4565 RVA: 0x00046578 File Offset: 0x00044778
|
|
public static DateTime AddYears(DateTime time, int years)
|
|
{
|
|
int num = CCFixed.FromDateTime(time);
|
|
int num2;
|
|
int num3;
|
|
int num4;
|
|
CCGregorianCalendar.dmy_from_fixed(out num2, out num3, out num4, num);
|
|
num4 += years;
|
|
int daysInMonth = CCGregorianCalendar.GetDaysInMonth(num4, num3);
|
|
if (num2 > daysInMonth)
|
|
{
|
|
num2 = daysInMonth;
|
|
}
|
|
num = CCGregorianCalendar.fixed_from_dmy(num2, num3, num4);
|
|
return CCFixed.ToDateTime(num).Add(time.TimeOfDay);
|
|
}
|
|
|
|
// Token: 0x060011D6 RID: 4566 RVA: 0x000465D0 File Offset: 0x000447D0
|
|
public static int GetDayOfMonth(DateTime time)
|
|
{
|
|
return CCGregorianCalendar.day_from_fixed(CCFixed.FromDateTime(time));
|
|
}
|
|
|
|
// Token: 0x060011D7 RID: 4567 RVA: 0x000465E0 File Offset: 0x000447E0
|
|
public static int GetDayOfYear(DateTime time)
|
|
{
|
|
int num = CCFixed.FromDateTime(time);
|
|
int num2 = CCGregorianCalendar.year_from_fixed(num);
|
|
int num3 = CCGregorianCalendar.fixed_from_dmy(1, 1, num2);
|
|
return num - num3 + 1;
|
|
}
|
|
|
|
// Token: 0x060011D8 RID: 4568 RVA: 0x0004660C File Offset: 0x0004480C
|
|
public static int GetDaysInMonth(int year, int month)
|
|
{
|
|
int num = CCGregorianCalendar.fixed_from_dmy(1, month, year);
|
|
int num2 = CCGregorianCalendar.fixed_from_dmy(1, month + 1, year);
|
|
return num2 - num;
|
|
}
|
|
|
|
// Token: 0x060011D9 RID: 4569 RVA: 0x00046630 File Offset: 0x00044830
|
|
public static int GetDaysInYear(int year)
|
|
{
|
|
int num = CCGregorianCalendar.fixed_from_dmy(1, 1, year);
|
|
int num2 = CCGregorianCalendar.fixed_from_dmy(1, 1, year + 1);
|
|
return num2 - num;
|
|
}
|
|
|
|
// Token: 0x060011DA RID: 4570 RVA: 0x00046654 File Offset: 0x00044854
|
|
public static int GetMonth(DateTime time)
|
|
{
|
|
return CCGregorianCalendar.month_from_fixed(CCFixed.FromDateTime(time));
|
|
}
|
|
|
|
// Token: 0x060011DB RID: 4571 RVA: 0x00046664 File Offset: 0x00044864
|
|
public static int GetYear(DateTime time)
|
|
{
|
|
return CCGregorianCalendar.year_from_fixed(CCFixed.FromDateTime(time));
|
|
}
|
|
|
|
// Token: 0x060011DC RID: 4572 RVA: 0x00046674 File Offset: 0x00044874
|
|
public static bool IsLeapDay(int year, int month, int day)
|
|
{
|
|
return CCGregorianCalendar.is_leap_year(year) && month == 2 && day == 29;
|
|
}
|
|
|
|
// Token: 0x060011DD RID: 4573 RVA: 0x00046690 File Offset: 0x00044890
|
|
public static DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int milliseconds)
|
|
{
|
|
return CCFixed.ToDateTime(CCGregorianCalendar.fixed_from_dmy(day, month, year), hour, minute, second, (double)milliseconds);
|
|
}
|
|
|
|
// Token: 0x0400046F RID: 1135
|
|
private const int epoch = 1;
|
|
|
|
// Token: 0x0200016D RID: 365
|
|
public enum Month
|
|
{
|
|
// Token: 0x04000471 RID: 1137
|
|
january = 1,
|
|
// Token: 0x04000472 RID: 1138
|
|
february,
|
|
// Token: 0x04000473 RID: 1139
|
|
march,
|
|
// Token: 0x04000474 RID: 1140
|
|
april,
|
|
// Token: 0x04000475 RID: 1141
|
|
may,
|
|
// Token: 0x04000476 RID: 1142
|
|
june,
|
|
// Token: 0x04000477 RID: 1143
|
|
july,
|
|
// Token: 0x04000478 RID: 1144
|
|
august,
|
|
// Token: 0x04000479 RID: 1145
|
|
september,
|
|
// Token: 0x0400047A RID: 1146
|
|
october,
|
|
// Token: 0x0400047B RID: 1147
|
|
november,
|
|
// Token: 0x0400047C RID: 1148
|
|
december
|
|
}
|
|
}
|
|
}
|