static class · System

Dates

static class Dates

The calendar's arithmetic (proleptic Gregorian, days since 0001-01-01).

Tipo
static class
Espacio de nombres
System
Ensamblado
System.Core
Acceso
internal, static, abstract
Archivo fuente
Time.ant

Herencia

Clases base
Any Dates

Métodos

Clock() : i64
#

static

Now, in ticks since 1970-01-01 UTC.

DaysOf(i32 year, i32 month, i32 day) : i64
#

static

The days from 0001-01-01 to a date (not checked): days from 0000-03-01, with January and February the last months of the year before.

MonthLength(i32 year, i32 month) : i32
#

static

The days in a month (both already checked).

YearOf(u64 ticks) : i32
#

static

The year of a tick count.

Parts(u64 ticks) : u32
#

static

The year, month and day of a tick count as year << 9 | month << 5 | day (Neri and Schneider's method, as .NET does it: one division per part).

Miembros privados e internos (1)

extern("time.utc") Utc() : i64
#

private static

Miembros heredados (5)

Código fuente

Dates en Antril, descompilado a partir de su Larva HIR.

System.Dates.ant
// System.Dates — System.Core (decompiled from Larva HIR)

into namespace System
{
	/// The calendar's arithmetic (proleptic Gregorian, days since 0001-01-01).
	static class Dates
	{
		extern("time.utc") Utc() : i64;

		public:
			/// Now, in ticks since 1970-01-01 UTC.
			Clock() : i64 => Utc();

			/// The days from 0001-01-01 to a date (not checked): days from 0000-03-01, with January and February the
			/// last months of the year before.
			DaysOf(i32 year, i32 month, i32 day) : i64
			{
				i32 y = year;
				i32 m = month;
				if (m < 3)
				{
					y--;
					m += 12;
				}
				i32 centuries = y / 100;
				return (i64)y * 365 + (i64)(y >> 2) - (i64)centuries + (i64)(centuries >> 2) + (153 * (i64)m - 457) / 5 + (i64)day - 307;
			}

			/// The days in a month (both already checked).
			MonthLength(i32 year, i32 month) : i32
			{
				if (month != 2)
					return 30 + (month + (month >> 3) & 1);
				return (year & 3) == 0 && (year % 100 != 0 || year % 400 == 0) ? 29 : 28;
			}

			/// The year of a tick count.
			YearOf(u64 ticks) : i32
			{
				u32 quarters = (u32)(ticks / 216000000000) | 3;
				u32 cycles = quarters / 146097;
				u32 rest = quarters % 146097;
				return (i32)(1 + 100 * cycles + (rest | 3) / 1461);
			}

			/// The year, month and day of a tick count as `year << 9 | month << 5 | day` (Neri and Schneider's method,
			/// as .NET does it: one division per part).
			Parts(u64 ticks) : u32
			{
				u32 quarters = ((u32)(ticks / 216000000000) | 3) + 1224;
				u32 centuries = quarters / 146097;
				u32 rest = quarters % 146097;
				u64 scaled = 2939745 * ((u64)rest | 3);
				u32 sinceMarch = (u32)scaled / 11758980;
				u32 monthDay = 2141 * sinceMarch + 197913;
				u32 year = 100 * centuries + (u32)(scaled >> 32);
				u32 month = monthDay >> 16;
				u32 day = (monthDay & 65535) / 2141 + 1;
				if (sinceMarch >= 306)
				{
					year++;
					month -= 12;
				}
				return year << 9 | month << 5 | day;
			}
	}
}
Esc