SW Combine SDK
    Preparing search index...

    Class Timestamp

    Utility class for working with Star Wars Combine timestamps. Represents Combine Galactic Time and can convert unix timestamps and Date objects to/from CGT.

    Index

    Constructors

    Methods

    • Get the day component

      Returns number

      Day of the year (1-365)

    • Calculate the duration from this timestamp to another timestamp

      Parameters

      Returns Duration

      Duration between timestamps (positive if other is in future)

    • Get the hour component

      Returns number

      Hour of the day (0-23)

    • Get the minute component

      Returns number

      Minute of the hour (0-59)

    • Get the second component

      Returns number

      Second of the minute (0-59)

    • Calculate a new timestamp by subtracting time from this timestamp

      Parameters

      • duration: Partial<Duration>

        Duration to subtract (partial duration allowed)

      Returns Timestamp

      New Timestamp with subtracted duration (won't go before SWC start)

    • Convert the CGT timestamp into a Date object

      Returns Date

      JavaScript Date object

    • Convert the CGT timestamp to a string

      You can either pass in a preset name, or a custom format string.

      Preset formats:

      • 'full': Year 25 Day 60, 6:03:12
      • 'minute': Year 25 Day 60, 6:03
      • 'day': Year 25 Day 60
      • 'shortFull': Y25 D60, 6:03:12
      • 'shortMinute': Y25 D60, 6:03
      • 'shortDay': Y26 D60

      Custom format tags:

      • {y}: year
      • {d}: day
      • {h}: hour
      • {m}: minute
      • {s}: second
      • Double the tag for leading zeroes (e.g., {hh} = 08)
      • {hms}: shorthand for {hh}:{mm}:{ss}

      Parameters

      • format: string = 'full'

        Preset format name or custom format string

      Returns string

      Formatted timestamp string

    • Convert a Date object into Combine Galactic Time

      Parameters

      • date: Date

        JavaScript Date object

      Returns Timestamp

      Timestamp instance representing the CGT moment

    • Convert a unix timestamp to Combine Galactic Time

      Parameters

      • unixTimestamp: number

        Unix timestamp (seconds or milliseconds, auto-detected)

      Returns Timestamp

      Timestamp instance representing the CGT moment