Grounds
    Preparing search index...

    Function Timestamp

    • Creates a timestamp Relish value.

      Timestamps represent Unix epoch time (seconds since 1970-01-01 00:00:00 UTC) as a 64-bit signed integer. When decoded, produces a Luxon DateTime object.

      Parameters

      • unixSeconds: bigint

        BigInt representing seconds since Unix epoch

      Returns RelishTimestamp

      RelishTimestamp value

      import { Timestamp, encode } from '@grounds/core';

      // Encode current time
      const now = BigInt(Math.floor(Date.now() / 1000));
      const timestamp = Timestamp(now);
      encode(timestamp).match(
      (bytes) => console.log('Timestamp encoded:', bytes),
      (error) => console.error(error)
      );

      Precision is seconds (no milliseconds or microseconds). For nanosecond precision, encode as a struct with separate second and nanosecond fields.

      U64 for raw 64-bit integers