npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dni-cavern-time

v2.0.0

Published

D'ni Date-Time Converter Package

Downloads

201

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.

Wikipedia - Myst & The D'ni

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:

  1. 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.

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;
  1. 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.

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);
  1. 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.

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());
  1. 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.

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

  1. The following command will run the package tests: npm run test

More Resources

Check out work done by others regarding D'ni Timekeeping!

  1. 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.
  2. 25-Hour Digital Myst Clock/Chronometer by Real Of Rium+
  3. General D'ni Time Wiki by the Guild of Archivists
  4. D'ni Time Conversion Wiki
  5. 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.