Fictional time allows you to create, display and convert units to and from your own (symetric) fictional time.
meteor add storyteller:fictionaltime
Now you can create your own fictional time anywhere in the code like this:
const myTime = new FictionalTime({connectedToET: false, beginning: false, units: [10, 100, 1000], separators: [":", ":"], declaration: "SUT", declarationLocation: "before"});
In order to create a time you need the following values:
- Array with the length of each unit in milliseconds
- Begging date for your time in milliseconds (use
new Date("your date").valueOf()
or the same with Moment.js) if you choose to lock it with Earth Time. - Unit separators array with time declarator (this means that the first value in the array is for what will be display before the time itself and the same goes for the last value, so a GMT unit separators in American style would look like this:
["/", "/", " ", ":", ":"]
) - Declarator that will be placed "before" (
'Earth Time '
), "after" (' GMT'
) or at "both" ends (['Earth Time ', ' GMT']
) - don't forget the spaces - or "none". - Where is the main unit declaration located at, options are: before, after, both, false
First add the package to your project:
meteor add storyteller:fictionaltime
Then you can initialize fictional time anywhere in your code.
const sut = {
connectedToET: false,
beginning: false,
units: [500, 10, 100, 100, 1000],
separators: [".", " ", ":", ":"],
declaration: "SUT ",
declarationLocation: "before"
};
const sutTime = new FictionalTime(sut);
toTime(milliseconds)
milliseconds - the number of milliseconds you want to dispaly in the time
TODO: shorten the displayed time only to the relevant units
Example:
sut.toTime(100000)
Will return "0.000 0:01:00".
toDate(milliseconds)
milliseconds - the number of milliseconds you want to dispaly in the time
Same as toTime, but it also includes all the units and declaration.
Example:
sutTime.toDate(100000);
Will return "SUT 0.000 0:01:00".
toUnit(milliseconds, position)
milliseconds - the number of milliseconds you want to convert to a given unit
position - position of the unit in the units array you provided in the definition of the time
Example:
sut.toUnit(50000000000, 0);
Will return 1.
unitToMilliseconds(count, unit)
milliseconds - the number of milliseconds you want to convert to a given unit
position - position of the unit in the units array you provided in the definition of the time
Opposite of toUnit, will return milliseconds to of the given unit.
Example:
sut.unitToMilliseconds(1, 0);
Will return 50000000000.
If your time has an establishment date, then you can use this to display your current fictional date time.
sut.currentDateTime();
If your time has an establishment date, then you can create a countdown to a certain Earth date and time.
sut.countdown(new Date('2400-01-01').getMilliseconds());