All files / src/lib timestamp.format.lib.ts

100% Statements 60/60
100% Branches 24/24
100% Functions 2/2
100% Lines 60/60

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 601x 1x 1x 1x 1x 1x 1x 1x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 5x 5x 5x 5x 25x 25x 25x 5x 5x 5x 5x 20x 25x 25x 25x 25x 25x 25x 25x 25x 18x 25x 2x 25x 2x 25x 3x 25x 25x 25x 25x 25x 25x 25x
import DniGorahyan from "../index";
import UtilsLib from "./utils.lib";
import { setNthBell } from "./surface.converter.lib";
import { toBase25 } from "./base.25.lib";
 
const { padValue } = UtilsLib();
 
export const TimestampFormatLoaders = (dniGorahyan: DniGorahyan) => {
    const dniDateTimeStringFormatter = function(): string {
        let
            constructedBell = "",
            paddedTahvo = padValue(dniGorahyan.tahvotee),
            paddedGorahn = padValue(dniGorahyan.gorahntee),
            paddedProrahn = padValue(dniGorahyan.prorahntee),
            dateIsBE = dniGorahyan.hahrtee < 0,
            resolvedVaileeText = dniGorahyan.useDniFontMapping ?
                dniGorahyan.vaileeDniFontMappingName : dniGorahyan.vaileeTextName,
            hahrteeShift = dateIsBE ?
                (dniGorahyan.hahrtee * -1) : dniGorahyan.hahrtee,
            epochStamp = (dateIsBE && dniGorahyan.useDniFontMapping) ?
                " be" : dateIsBE ?
                    " BE" : dniGorahyan.useDniFontMapping ? " de" : " DE";
 
        // Set Time and Date String
        let
            constructedTime = dniGorahyan.useDniFontMapping ?
                toBase25(dniGorahyan.gahrtahvotee) + ":" +
                toBase25(dniGorahyan.tahvotee) + ":" +
                toBase25(dniGorahyan.gorahntee) + ":" +
                toBase25(dniGorahyan.prorahntee)
                : dniGorahyan.gahrtahvotee + ":" + paddedTahvo + ":" + paddedGorahn + ":" + paddedProrahn,
            constructedDate =
                dniGorahyan.useDniFontMapping ?
                resolvedVaileeText + " " +
                    toBase25(dniGorahyan.yahrtee) + ", " +
                    toBase25(hahrteeShift) +
                    epochStamp
                    : resolvedVaileeText + " " + dniGorahyan.yahrtee + ", " + hahrteeShift + epochStamp
 
        if(dniGorahyan.outputType === 0 || dniGorahyan.includeNthBell) {
            constructedBell = setNthBell(dniGorahyan.pahrtahvotee);
            constructedBell += dniGorahyan.useDniFontMapping ? " bell, " : " Bell, ";
        }
 
        switch(dniGorahyan.outputType) {
            case 0:
                return `${constructedBell}${constructedTime}, ${constructedDate}`;
            case 1:
                return `${constructedDate} ${constructedTime}`;
            case 2:
                return `${constructedTime}, ${constructedDate}`;
            default:
                return `${constructedBell}${constructedTime}, ${constructedDate}`;
        }
    }
 
    return {
        dniDateTimeStringFormatter
    };
}