Class XTimeSpan
Additional members to supplement the TimeSpan class.
Mostly constants.
For consistency with TimeSpan, I've used long as the type for any integer constants.
For non-integer constants I've used double.
The following constants are already provided by the TimeSpan class and not reproduced here:
- TicksPerMicrosecond
- TicksPerMillisecond
- TicksPerSecond
- TicksPerMinute
- TicksPerHour
- TicksPerDay
NOTE: Any constants or methods for converting between time units will become obsolete with the completion of Galaxon.Quantities.
The word Month, Year, Decade, Century, or Millennium in a constant name usually refers to the average length of that time unit in the Gregorian Calendar.
Inheritance
Namespace: Galaxon.Core.Time
Assembly: Galaxon.Core.dll
Syntax
public static class XTimeSpan : object
Fields
CommonYearsPerSolarCycle
The number of common years in a Gregorian solar cycle.
Declaration
public const long CommonYearsPerSolarCycle = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
DaysPerCentury
The average number of days in a Gregorian century.
Declaration
public const double DaysPerCentury = null
Field Value
| Type | Description |
|---|---|
| System.Double |
DaysPerDecade
The average number of days in a Gregorian decade.
Declaration
public const double DaysPerDecade = null
Field Value
| Type | Description |
|---|---|
| System.Double |
DaysPerJulianCentury
The number of days in a Julian Calendar century.
Declaration
public const long DaysPerJulianCentury = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
DaysPerJulianDecade
The number of days in a Julian Calendar decade.
Declaration
public const double DaysPerJulianDecade = null
Field Value
| Type | Description |
|---|---|
| System.Double |
DaysPerJulianMillennium
The number of days in a Julian Calendar millennium.
Declaration
public const long DaysPerJulianMillennium = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
DaysPerJulianYear
The number of days in a Julian Calendar year.
Declaration
public const double DaysPerJulianYear = null
Field Value
| Type | Description |
|---|---|
| System.Double |
DaysPerLunation
Number of days in a synodic lunar month (a.k.a. "lunation").
Declaration
public const double DaysPerLunation = null
Field Value
| Type | Description |
|---|---|
| System.Double |
DaysPerMillennium
The average number of days in a Gregorian millennium.
Declaration
public const double DaysPerMillennium = null
Field Value
| Type | Description |
|---|---|
| System.Double |
DaysPerMonth
The average number of days in a Gregorian month.
Declaration
public const double DaysPerMonth = null
Field Value
| Type | Description |
|---|---|
| System.Double |
DaysPerSolarCycle
The number of days in a Gregorian solar cycle.
Declaration
public const long DaysPerSolarCycle = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
DaysPerTropicalYear
The number of days in the mean tropical year B1900 (days). This value is taken from the SOFA (Standards of Fundamental Astronomy) library, which is assumed to be authoritative.
Declaration
public const double DaysPerTropicalYear = null
Field Value
| Type | Description |
|---|---|
| System.Double |
DaysPerWeek
The number of days in a week.
Declaration
public const long DaysPerWeek = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
DaysPerYear
The average number of days in a Gregorian year.
Declaration
public const double DaysPerYear = null
Field Value
| Type | Description |
|---|---|
| System.Double |
HoursPerDay
The number of hours in an ephemeris day.
Declaration
public const long HoursPerDay = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
HoursPerWeek
The number of hours in a week.
Declaration
public const long HoursPerWeek = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
LeapYearsPerSolarCycle
The number of leap years in a Gregorian solar cycle.
Declaration
public const long LeapYearsPerSolarCycle = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
MinutesPerDay
The number of minutes in a day.
Declaration
public const long MinutesPerDay = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
MinutesPerHour
The number of minutes in an hour.
Declaration
public const long MinutesPerHour = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
MonthsPerSolarCycle
The number of months in a Gregorian solar cycle.
Declaration
public const long MonthsPerSolarCycle = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
MonthsPerYear
The number of months in a Gregorian year.
Declaration
public const long MonthsPerYear = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
OlympiadsPerSolarCycle
Number of olympiads in an Gregorian solar cycle.
Declaration
public const long OlympiadsPerSolarCycle = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
SecondsPerCentury
The average number of seconds in a Gregorian century.
Declaration
public const long SecondsPerCentury = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
SecondsPerDay
The number of seconds in an ephemeris day.
Declaration
public const long SecondsPerDay = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
SecondsPerDecade
The average number of seconds in a Gregorian decade.
Declaration
public const long SecondsPerDecade = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
SecondsPerHour
The number of seconds in an hour.
Declaration
public const long SecondsPerHour = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
SecondsPerMicrosecond
The number of seconds in a microsecond.
Declaration
public const double SecondsPerMicrosecond = null
Field Value
| Type | Description |
|---|---|
| System.Double |
SecondsPerMillennium
The average number of seconds in a Gregorian millennium.
Declaration
public const long SecondsPerMillennium = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
SecondsPerMillisecond
The number of seconds in a millisecond.
Declaration
public const double SecondsPerMillisecond = null
Field Value
| Type | Description |
|---|---|
| System.Double |
SecondsPerMinute
The number of seconds in a minute.
Declaration
public const long SecondsPerMinute = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
SecondsPerMonth
The average number of seconds in a month.
Declaration
public const long SecondsPerMonth = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
SecondsPerSolarDay
The number of seconds in a solar day (as at 2023). It is increasing by about 2 milliseconds per century.
Declaration
public const double SecondsPerSolarDay = null
Field Value
| Type | Description |
|---|---|
| System.Double |
SecondsPerTick
The number of seconds in a nanosecond.
Declaration
public const double SecondsPerTick = null
Field Value
| Type | Description |
|---|---|
| System.Double |
SecondsPerWeek
The number of seconds in a week.
Declaration
public const long SecondsPerWeek = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
SecondsPerYear
The average number of seconds in a Gregorian year.
Declaration
public const long SecondsPerYear = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
TicksPerCentury
The number of ticks in a Gregorian century.
Declaration
public const long TicksPerCentury = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
TicksPerDecade
The number of ticks in a Gregorian decade.
Declaration
public const long TicksPerDecade = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
TicksPerMillennium
The number of ticks in a Gregorian millennium.
Declaration
public const long TicksPerMillennium = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
TicksPerMonth
The number of ticks in a month.
Declaration
public const long TicksPerMonth = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
TicksPerNanosecond
The number of ticks in a nanosecond.
Declaration
public const double TicksPerNanosecond = null
Field Value
| Type | Description |
|---|---|
| System.Double |
TicksPerWeek
The number of ticks in a week.
Declaration
public const long TicksPerWeek = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
TicksPerYear
The number of ticks in a Gregorian year.
Declaration
public const long TicksPerYear = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
WeeksPerMonth
The number of weeks in an average Gregorian month.
Declaration
public const double WeeksPerMonth = null
Field Value
| Type | Description |
|---|---|
| System.Double |
WeeksPerSolarCycle
The number of weeks in a Gregorian solar cycle.
Declaration
public const long WeeksPerSolarCycle = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
WeeksPerYear
The number of weeks in a Gregorian year.
Declaration
public const double WeeksPerYear = null
Field Value
| Type | Description |
|---|---|
| System.Double |
YearsPerCentury
The number of years in a century.
Declaration
public const long YearsPerCentury = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
YearsPerDecade
The number of years in a decade.
The precise length of a decade depends on what year is being used. For a example, a Gregorian decade (3652.425 d on average) will have a different length to an Islamic Calendar decade (about 3543.67 d on average) or a tropical decade (3652.42198781 d on average).
Declaration
public const long YearsPerDecade = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
YearsPerMillennium
The number of years in a millennium.
Declaration
public const long YearsPerMillennium = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
YearsPerOlympiad
Number of years in an olympiad.
Declaration
public const long YearsPerOlympiad = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
YearsPerSolarCycle
The Gregorian Calendars repeats on a 400-year cycle called the solar cycle.
There are 97 leap years in that period, giving an average calendar year length of 365 + (97/400) = 365.2425 days/year.
1 Gregorian solar cycle = 400 y = 4800 mon = 20,871 w = 146,097 d
5 Gregorian solar cycles = 2000 y = 2 ky
Solar cycles are not ordinarily numbered, nor given a specific start date. However, within the proleptic Gregorian epoch (the one used by .NET), which began on Monday, 1 Jan, 1 AD, we are currently in the 6th solar cycle. It began on Monday, 1 Jan, 2001, which was also the first day of the 3rd millennium AD. It will end on Sunday, 31 Dec, 2400.
See:
Declaration
public const long YearsPerSolarCycle = null
Field Value
| Type | Description |
|---|---|
| System.Int64 |
Methods
Convert(Double, ETimeUnit, ETimeUnit)
Convert a time value from one unit to another. TODO Replace with Quantity methods.
Declaration
public static double Convert(double amount, ETimeUnit fromUnit, ETimeUnit toUnit = ETimeUnit.Tick)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | amount | The amount. |
| ETimeUnit | fromUnit | The amount argument units. |
| ETimeUnit | toUnit | The result units. |
Returns
| Type | Description |
|---|---|
| System.Double | The amount of the new unit. |