Table of Contents

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

dateTime DateTime

The timestamp to pack; must be at or after MinValue.

PackedDateTime48(long, bool)

Constructs from either packed or unpacked ticks.

public PackedDateTime48(long value, bool isPacked)

Parameters

value long

Packed ticks when isPacked is true, otherwise unpacked DateTime ticks (≥ BaseTicks).

isPacked bool

true if value is already packed; false to 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

long

MinValue

Smallest representable value — the 1970-01-01T00:00:00Z epoch (a DateTime at BaseTicks).

public static readonly DateTime MinValue

Field Value

DateTime

PackedShift

Number of low bits dropped from the tick count when packing (10), trading precision for range.

public const int PackedShift = 10

Field Value

int

PackedTickResolution

Effective resolution of one packed tick, in seconds (≈102.4 µs).

public const double PackedTickResolution = 0.0001024

Field Value

double

Properties

PackedTicks

The raw 48-bit packed tick count (epoch-relative and shifted).

public long PackedTicks { get; }

Property Value

long

Ticks

The unpacked DateTime ticks this value represents. The round-trip is lossy — precision is PackedTickResolution.

public long Ticks { get; }

Property Value

long

UtcNow

The current UTC time, packed.

public static PackedDateTime48 UtcNow { get; }

Property Value

PackedDateTime48

Methods

FromDateTimeTicks(long)

Creates a value from unpacked DateTime ticks (must be ≥ BaseTicks).

public static PackedDateTime48 FromDateTimeTicks(long ticks)

Parameters

ticks long

Unpacked DateTime ticks.

Returns

PackedDateTime48

FromPackedDateTimeTicks(long)

Creates a value from an already-packed tick count (see PackedTicks).

public static PackedDateTime48 FromPackedDateTimeTicks(long ticks)

Parameters

ticks long

Packed ticks.

Returns

PackedDateTime48

ToDateTimeTicks(long)

Converts packed ticks back to unpacked DateTime ticks (shift left by PackedShift, add BaseTicks).

public static long ToDateTimeTicks(long packedTicks)

Parameters

packedTicks long

Packed 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

dateTimeTicks long

Unpacked DateTime ticks.

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

string

Operators

explicit operator PackedDateTime48(DateTime)

Packs a DateTime from its raw Ticks.

public static explicit operator PackedDateTime48(DateTime dateTime)

Parameters

dateTime DateTime

Returns

PackedDateTime48

explicit operator DateTime(PackedDateTime48)

Unpacks to a DateTime.

public static explicit operator DateTime(PackedDateTime48 packed)

Parameters

packed PackedDateTime48

Returns

DateTime