PhoenixmlDb.Core
XsDateTime
Represents an xs:dateTime value with explicit timezone tracking and support for extended years outside the .NET range.
#XsDateTime
Namespace: PhoenixmlDb.Xdm
Represents an
xs:dateTime
value with explicit timezone tracking and support for extended years outside the .NET
range.
Unlike DateTimeOffset, this type distinguishes between "no timezone" and "UTC timezone" (Z). In XML Schema, 2024-01-15T10:00:00 (no timezone) and 2024-01-15T10:00:00Z (UTC) are semantically different — the former uses the implicit timezone for comparisons, while the latter is explicitly UTC.
Extended years: XML Schema allows years outside the 1-9999 range (including year 0 and negative years in the proleptic Gregorian calendar). When XsDateTime.ExtendedYear is non-null, it holds the true year while XsDateTime.Value's year is clamped to a valid .NET range for time-of-day storage.
Comparison: Follows the XPath Functions and Operators specification. Values with timezones are normalized to UTC; values without timezones use the implicit (system) timezone.
#Constructors
##ctor(DateTimeOffset,Boolean)
Represents an
xs:dateTime
value with explicit timezone tracking and support for extended years outside the .NET
range.
Unlike DateTimeOffset, this type distinguishes between "no timezone" and "UTC timezone" (Z). In XML Schema, 2024-01-15T10:00:00 (no timezone) and 2024-01-15T10:00:00Z (UTC) are semantically different — the former uses the implicit timezone for comparisons, while the latter is explicitly UTC.
Extended years: XML Schema allows years outside the 1-9999 range (including year 0 and negative years in the proleptic Gregorian calendar). When XsDateTime.ExtendedYear is non-null, it holds the true year while XsDateTime.Value's year is clamped to a valid .NET range for time-of-day storage.
Comparison: Follows the XPath Functions and Operators specification. Values with timezones are normalized to UTC; values without timezones use the implicit (system) timezone.
#Properties
| Name | Description |
|---|---|
EffectiveYear
|
The effective year, using ExtendedYear if available, otherwise Value.Year. |
ExtendedYear
|
Extended year for dateTimes outside the .NET DateTimeOffset range (years < 1 or > 9999). When non-null, this is the true year; Value.Year is clamped for time storage. |
FractionalTicks
|
Fractional seconds preserved from parsing (sub-tick precision not needed, but format is preserved). |
#Methods
#Add(TimeSpan)
Adds a duration (dayTimeDuration) using a proleptic day-number conversion so that crossings below year 1 are handled uniformly. Whole days are added via the day-number path; the remaining time-of-day is applied with day carry.
#AddMonths(Int64)
Adds (or subtracts, when negative) a number of months using proleptic-Gregorian month arithmetic on the effective year, clamping the day to the new month's length.
#CivilFromDays(Int64)
Converts a day count (since 1970-01-01) back to proleptic-Gregorian (year, month, day).
#DaysFromCivil(Int64,Int32,Int32)
Days since 1970-01-01 for any proleptic-Gregorian y/m/d (Howard Hinnant's algorithm, correct for negative years).
#DaysInMonthProleptic(Int64,Int32)
Returns the number of days in a given month for a proleptic Gregorian year.
#FloorDiv(Int64,Int64)
Floor division — rounds toward negative infinity (unlike C# integer division).
#FloorMod(Int64,Int64)
Floor modulo — result has the same sign as the divisor.
#FromProleptic(Int64,Int32,Int32,TimeOnly,Int32,TimeSpan,Boolean)
Builds an
from a proleptic (year, month, day) and a time-of-day, setting ExtendedYear when the year falls outside the .NET 1..9999 range.
#IsLeapYearProleptic(Int64)
Determines if a year is a leap year in the proleptic Gregorian calendar. XSD uses proleptic Gregorian where year 0 exists (= 1 BC in astronomical year numbering).