ChronosChronos

reconstruct

Reconstruct a Chronos instance from known properties.

reconstruct()

Rebuilds a Chronos instance from a ChronosProperties object.

Signature

static reconstruct(value: ChronosProperties): Chronos

Parameters

  • value: Object containing the properties required to reconstruct a Chronos instance

ChronosProperties Type

interface ChronosProperties {
  origin: LooseLiteral<ChronosMethods>;
  native: Date | string;
  utcOffset: UTCOffset;
  timeZoneName: LooseLiteral<TimeZoneName>;
  timeZoneId: TimeZoneId;
  $tzTracker?: $TimeZoneIdentifier | TimeZone | UTCOffset;
}

Return Type

Chronos - A newly reconstructed Chronos instance

Throws

  • TypeError if the input is not reconstructable

Example

import { Chronos } from "chronos-date";

const base = new Chronos('2025-04-06T16:11:55Z');
const snapshot = {
  native: base.native,
  origin: base.origin,
  utcOffset: base.utcOffset,
  timeZoneName: base.timeZoneName,
  timeZoneId: base.timeZoneId,
  $tzTracker: base.$tzTracker
};

if (Chronos.isReconstructable(snapshot)) {
  const restored = Chronos.reconstruct(snapshot);
  console.log(restored.toISOString()); // Same universal moment as base
  console.log(restored.origin); // Preserves metadata from snapshot
}

Example (Invalid Input)

playground.ts

Notes

  • reconstruct is intended for trusted serialized payloads with full Chronos metadata.
  • Internally, a new Chronos(native) is created and then metadata (origin, timezone details, tracker) is restored.
  • Prefer isReconstructable() before reconstructing unknown input.

Last updated: Thu, May 21, 2026 07:12:18AM (UTC)

On this page