Struct PackedDateTime48
- Namespace
- Typhon.Schema.Definition
- Assembly
- Typhon.Schema.Definition.dll
A 6-byte (48-bit) packed UTC timestamp: DateTime ticks offset from the 1970-01-01 epoch and shifted right by PackedShift bits, giving ~102.4 µs resolution in half the footprint of a DateTime. Values before MinValue are not representable.
public readonly struct PackedDateTime48
- Inherited Members
Constructors
PackedDateTime48(DateTime)
Packs the given dateTime from its raw Ticks.
public PackedDateTime48(DateTime dateTime)
Parameters
PackedDateTime48(long, bool)
Constructs from either packed or unpacked ticks.
public PackedDateTime48(long value, bool isPacked)
Parameters
valuelongPacked ticks when
isPackedistrue, otherwise unpacked DateTime ticks (≥ BaseTicks).isPackedbooltrueifvalueis already packed;falseto pack it.
Fields
BaseTicks
Epoch offset in DateTime ticks — the tick count at 1970-01-01T00:00:00Z, subtracted before packing.
public const long BaseTicks = 621355968000000000
Field Value
MinValue
public static readonly DateTime MinValue
Field Value
PackedShift
Number of low bits dropped from the tick count when packing (10), trading precision for range.
public const int PackedShift = 10
Field Value
PackedTickResolution
Effective resolution of one packed tick, in seconds (≈102.4 µs).
public const double PackedTickResolution = 0.0001024
Field Value
Properties
PackedTicks
The raw 48-bit packed tick count (epoch-relative and shifted).
public long PackedTicks { get; }
Property Value
Ticks
The unpacked DateTime ticks this value represents. The round-trip is lossy — precision is PackedTickResolution.
public long Ticks { get; }
Property Value
UtcNow
The current UTC time, packed.
public static PackedDateTime48 UtcNow { get; }
Property Value
Methods
FromDateTimeTicks(long)
public static PackedDateTime48 FromDateTimeTicks(long ticks)
Parameters
Returns
FromPackedDateTimeTicks(long)
Creates a value from an already-packed tick count (see PackedTicks).
public static PackedDateTime48 FromPackedDateTimeTicks(long ticks)
Parameters
tickslongPacked ticks.
Returns
ToDateTimeTicks(long)
Converts packed ticks back to unpacked DateTime ticks (shift left by PackedShift, add BaseTicks).
public static long ToDateTimeTicks(long packedTicks)
Parameters
packedTickslongPacked ticks.
Returns
- long
The equivalent DateTime ticks (quantized to PackedTickResolution).
ToPackedTicks(long)
Converts unpacked DateTime ticks to packed ticks (subtract BaseTicks, shift right by PackedShift).
public static long ToPackedTicks(long dateTimeTicks)
Parameters
Returns
- long
The packed tick count.
ToString()
Formats the value as a round-trippable UTC ISO-8601 string (yyyy-MM-ddTHH:mm:ss.fffffffK, invariant culture).
public override string ToString()
Returns
Operators
explicit operator PackedDateTime48(DateTime)
public static explicit operator PackedDateTime48(DateTime dateTime)
Parameters
dateTimeDateTime
Returns
explicit operator DateTime(PackedDateTime48)
Unpacks to a DateTime.
public static explicit operator DateTime(PackedDateTime48 packed)
Parameters
packedPackedDateTime48