The Star Wars Combine game world runs on its own calendar called Combine Galactic Time (CGT). CGT counts from the game’s origin date of 3 December 1998 at 07:00:00 UTC, so a CGT year maps to a real-world year of 365 days. The SDK’s Timestamp class lets you create, format, compare, and do arithmetic on CGT moments — and convert freely between CGT, JavaScript Date objects, and Unix timestamps.
Creating a Timestamp
There are three static factory methods and one direct constructor.
Static factories
Direct constructor
Pass a TimestampMoment object. Only year and day are required; hour, minute, and second default to 0.
day is 1-indexed — valid values are 1 through 365. The constructor throws a RangeError if
any field is out of range.
Reading components
Use the getter methods to read individual CGT components:
To get all components at once as a plain object, use asMoment():
toString() accepts either a preset name or a custom template string.
Custom template strings
Use curly-brace tags in your own template. Double a tag letter to get zero-padded output.
Arithmetic
add() and subtract() accept a partial duration object — include only the fields you need. Both methods return a new Timestamp and do not mutate the original.
subtract() will never go before the SWC origin date. If the subtraction would underflow, the
result is clamped to Year 0 Day 1.
Measuring the gap between two timestamps
getDurationTo() returns the full duration between two Timestamp instances as a Duration object:
A negative duration is returned when the target is in the past relative to the source.
Comparing timestamps
Three methods let you compare two Timestamp instances:
Converting back to JavaScript types
Both 'sec' and 'seconds' are accepted as the unit string, as are 'ms' and 'milliseconds'.
Practical example: time remaining until an event
Combine the factory methods and getDurationTo() to display a countdown in your application: