1.0.2 • Published 7 years ago
asgardia-calendar-converter v1.0.2
asgardia-calendar-converter
Convert dates between ISO (Gregorian) calendar and proposed Asgardian calendar back and forth
Leap Days
Per Decree #2:
The question of adding an extra day in a leap year will be addressed separately.
This means that any date outside 2017 can be affected by the later-proposed leap day adaptation. I've come up with three different approaches that I find to be the most likely:
"feb": Leap Day is included between February and March (similar to ISO calendar)"jun": Leap Day is included between June and Asgard (similar to original International Fixed Calendar)"non": no Leap Day is ever included
Use the keyword of your selected mode in all calls to convert functions (see API).
Install
npm install --save asgardia-calendar-converterUsage
Import:
import {toAsgardian, toGregorian} from "asgardia-calendar-converter";or require:
const {toAsgardian, toGregorian} = require("asgardia-calendar-converter");and use the provided functions:
console.log(toAsgardian({day: 1, month: 7, year: 2017}, "non")); // logs {day: 14, month: 7, year: 1}
console.log(toGregorian({day: 1, month: 6, year: 1}, "non")); // logs {day: 21, month: 5, year: 2017}API
Datum
interface Datum {
day: number;
month: number;
year: number;
}toAsgardian
function toAsgardian(datum: Datum, mode: "feb" | "jun" | "non"): Datum;datum: ISODatumobject to be converted to Asgardianmode: Leap-day mode to be used (see Leap Days)
toGregorian
function toGregorian(datum: Datum, mode: "feb" | "jun" | "non"): Datum;datum: AsgardianDatumobject to be converted to ISOmode: Leap-day mode to be used (see Leap Days)
isAsgardianYearLeap
function isAsgardianYearLeap(year: number): Datum;year: Asgardian year to be checked whether it is leap or not
isGregorianYearLeap
function isGregorianYearLeap(year: number): Datum;year: ISO year to be checked whether it is leap or not
Development
Clone the repo and install dev-dependencies:
git clone url/of/your/fork
cd path/to/your/clone
npm installCompile files from src to dist:
npm run buildWatch src and compile files from there to dist on change:
npm run watchRun tests:
npm testCompile files for demo to out:
npm run build-demo