dni-cavern-time
v2.0.0
Published
D'ni Date-Time Converter Package
Downloads
201
Maintainers
Readme
D'ni Cavern And Surface Time Converters
This package facilitates the conversion of javascript date time objects or strings to D'ni formatted date-time strings and D'ni date time strings to javascript date time objects.
Table of Contents
Installation
This package is available through the npm registry. Before installing, download and install Node.js. Node.js 20 or higher is suggested.
If this is a new project, make sure to create a package.json first with the npm init command.
Installation is done using the npm install command:
$ npm install dni-cavern-time
Usage
The D'ni Cavern Time Converter Package exports a default function called initDniGorahyan which once called, returns a new instance of a DniGorahyan Class.
The following methods become available to run:
- surfaceToCavern(surfaceDateTime?: Date | string | null | undefined, useDniFontMapping?: boolean): string
- This function
- Accepts
- Returns: string - Dn'i Datetime Formatted
- Note: D'ni Font Mapping is meant to be used with a proper D'ni Font File.
- This function
Example: ES6 Import Syntax - surfaceToCavern(surfaceDateTime?: Date | string | null | undefined):
import initDniGorahyan from 'dni-cavern-time';
let
dniTimeConverter = initDniGorahyan(),
{ surfaceToCavern } = dniTimeConverter.converters,
surfaceTimestampToConvertToDniDT = "1991-04-21T09:54:00"; // Dn'i Date Time Calendar Convergence, Provided time should be local.
const
usingString = surfaceToCavern(surfaceTimestampToConvertToDniDT),
usingDate = surfaceToCavern(new Date(surfaceTimestampToConvertToDniDT)),
usingDateAndDniFontMapping = surfaceToCavern(new Date(surfaceTimestampToConvertToDniDT), true),
usingCallWithNoParams = surfaceToCavern();
console.log(usingString); // => 1991-04-21T09:54:00 Always returns Leefo 1 9647 DE 0:00:00:00
console.log(usingDate); // => 1991-04-21T09:54:00 Always returns Leefo 1 9647 DE 0:00:00:00
console.log(usingDateAndDniFontMapping); // => 1991-04-21T09:54:00 Always returns LEfo 1 9647 DE 0:00:00:00
console.log(usingCallWithNoParams) // => Returns the user's system's current date-time in D'ni;
Example: CommonJs Import Syntax - surfaceToCavern(surfaceDateTime?: Date | string | null | undefined):
const dniTimeConverter = require('dni-cavern-time').default();
let { surfaceToCavern } = dniTimeConverter.converters,
surfaceTimestampToConvertToDniDT = "1991-04-21T09:54:00"; // Dn'i Date Time Calendar Convergence, Provided time should be local.
const
usingString = surfaceToCavern(surfaceTimestampToConvertToDniDT),
usingDate = surfaceToCavern(new Date(surfaceTimestampToConvertToDniDT)),
usingDate = surfaceToCavern(new Date(surfaceTimestampToConvertToDniDT), true),
usingCallWithNoParams = surfaceToCavern();
console.log(usingString); // => 1991-04-21T09:54:00 Always returns Leefo 1 9647 DE 0:00:00:00
console.log(usingDate); // => 1991-04-21T09:54:00 Always returns Leefo 1 9647 DE 0:00:00:00
console.log(usingDate); // => 1991-04-21T09:54:00 Always returns LEfo 1 9647 DE 0:00:00:00
console.log(usingCallWithNoParams) // => Returns the user's system's current date-time in D'ni;
- cavernToSurface(cavernDateTimeString: string): {}
- This function
- Accepts/Requires: Dn'i Datetime Formatted String Leetar 29 9680 DE 4:11:16:08
- Returns: object { utc: string, cavern: string, local: string }
- Note: Do not pass a D'ni Font Mapping Value - This will be handled in a later release.
- This function
Example: ES6 Import Syntax - cavernToSurface(surfaceDateTime: string):
import initDniGorahyan from 'dni-cavern-time';
let
dniTimeConverter = initDniGorahyan(),
{ cavernToSurface } = dniTimeConverter.converters,
dniTimestampToConvertToSurfaceDT = "Leefo 1 9647 DE 0:00:00:00";
const convertedTS = cavernToSurface(dniTimestampToConvertToSurfaceDT);
console.log(convertedTS);
Example: CommonJs Import Syntax - cavernToSurface(surfaceDateTime: string):
const dniTimeConverter = require('dni-cavern-time').default();
let { cavernToSurface } = dniTimeConverter.converters,
dniTimestampToConvertToSurfaceDT = "Leefo 1 9647 DE 0:00:00:00";
const convertedTS = cavernToSurface(dniTimestampToConvertToSurfaceDT);
console.log(convertedTS);
- simulateCatastrophicObjectFailure(): Thrown Error
- This function:
- Accepts: No Parameters
- Returns: Thrown Error
Error: cavernToSurface(), surfaceToCavern(), or gorahyan{} is not initialized at DniGorahyan._handleUninitializedConstructorArtifact
- Purpose:
- To test the error handling when any of the DniGorahyan properties or methods are somehow overwritten.
- This function:
Example: ES6 Import Syntax - Simulate Catastrophic Failure:
import initDniGorahyan from 'dni-cavern-time';
let
dniTimeConverter = initDniGorahyan(),
{ simulateCatastrophicInitFailure } = dniTimeConverter.tests;
console.log(simulateCatastrophicInitFailure());
Example: CommonJs Import Syntax - Simulate Catastrophic Failure:
const dniTimeConverter = require('dni-cavern-time').default();
let { simulateCatastrophicInitFailure } = dniTimeConverter.tests;
console.log(simulateCatastrophicInitFailure());
- runControlTests(): {}
- This function:
- Accepts: No Parameters
- Returns: Object { runtimeMetrics, generated: { first_test_results: string, second_test_results: string, third_test_results: string, fourth_test_results: { utc: string, cavern: string, local: string }, fifth_test_results: { utc: string, cavern: string, local: string }, sixth_test_results: { utc: string, cavern: string, local: string }, } }
- Purpose:
- To Execute Associated DniGorahyan Functions And Confirm Return Values of Known Date Conversions.
- Functions Executed:
- first_test_results: surfaceToCavern() => Date defaults to new Date(), Returns formatted to D'ni DateTime,
- second_test_results: surfaceToCavern(
'1991-04-21T09:54:00'
) => Returns string formatted to D'ni DateTime, - third_test_results: surfaceToCavern(
new Date('1991-04-21T09:54:00')
) => Returns string formatted to D'ni DateTime, - fourth_test_results: cavernToSurface(
'Leefo 1 9647 DE 0:00:00:00'
) => Returns object with UTC, Cavern, and Local DateTimes, - fifth_test_results: cavernToSurface(
'Leevofo 8 9798 DE 2:13:00:00'
) => Returns object with UTC, Cavern, and Local DateTimes, - sixth_test_results: cavernToSurface(
'Leevosahn 5 9000 BE 1:05:06:07'
) => Returns object with UTC, Cavern, and Local DateTimes in earth notation.
- This function:
Example: ES6 Import Syntax - Run Control Tests:
import initDniGorahyan from 'dni-cavern-time';
let
dniTimeConverter = initDniGorahyan(),
{ runControlTests } = dniTimeConverter.tests;
console.log(runControlTests());
Example: CommonJs Import Syntax - Run Control Tests:
const dniTimeConverter = require('dni-cavern-time').default();
let { runControlTests } = dniTimeConverter.tests;
console.log(runControlTests());
Jest Test Suites
The last run coverage test report may be viewed here.
This package utilizes the Jest Testing Framework to test the code contained within this package.
All tests are found at the following directory structure and this is where all tests should be placed: src/test
The naming convention for test files should follow the format:
src/test/<dot-notation-filename>.test.ts
- The following command will run the package tests:
npm run test
More Resources
Check out work done by others regarding D'ni Timekeeping!
- D'ni Time Converter Program by @alahmnat (On Twitter). Based on work by RIUM+, Jehon the Scribe, and rokama. Additional contributions by Brett Middleton on the Guild of Archivists.
- 25-Hour Digital Myst Clock/Chronometer by Real Of Rium+
- General D'ni Time Wiki by the Guild of Archivists
- D'ni Time Conversion Wiki
- Original Source Code Based on work by RIUM+, Jehon the Scribe, and rokama. Additional contributions by Brett Middleton on the Guild of Archivists.
About
The first item in the More Resources Section is the inspiration for this npm package. I would not
have been able to create this package without the efforts of those who came before me. I have stored their original
work in the following location of this software package: src/archive/original.source.code.js
for posterity's sake and
to preserve their original work and my source.
The code has been updated and implemented using Node and TypeScript.
Contact And Bug Reporting
You can reach me at [email protected]
To report a Bug, please create an issue here.
License
This project is licensed under the MIT License.