* Moved Tests

+ Declare all new Types
This commit is contained in:
Daniel Legt 2022-05-07 14:11:24 +03:00
parent 97aa3e2281
commit 48a6d18c24
5 changed files with 42 additions and 4 deletions

View File

@ -6,6 +6,38 @@ export type commonDateFormats = "d/m/Y" | "m/d/Y" | "d/m/Y h:i A" | "d/m/Y H:i"
// ############################## [ Time Formats ] ############################## // ############################## [ Time Formats ] ##############################
// =-=-=-=-=-=-=-=-=-=-= [ Meridiem ] =-=-=-=-=-=-=-=-=-=-=
const mertypes = [ "a", "A" ];
/**
* Possible formats for the date
*/
export type meridiemType = (typeof mertypes)[number];
export const isMeridiemType = (x: any): x is meridiemType => mertypes.includes(x);
// =-=-=-=-=-=-=-=-=-=-= [ Hours ] =-=-=-=-=-=-=-=-=-=-=
const hourtypes = [ "g", "G", "h", "H" ];
/**
* Possible formats for the date
*/
export type hourType = (typeof hourtypes)[number];
export const isHourType = (x: any): x is hourType => hourtypes.includes(x);
// =-=-=-=-=-=-=-=-=-=-= [ Minutes ] =-=-=-=-=-=-=-=-=-=-=
const minutetypes = [ "g", "G", "h", "H" ];
/**
* Possible formats for the date
*/
export type minuteType = (typeof minutetypes)[number];
export const isMinuteType = (x: any): x is minuteType => minutetypes.includes(x);
// =-=-=-=-=-=-=-=-=-=-= [ Seconds ] =-=-=-=-=-=-=-=-=-=-=
const secondtypes = [ "g", "G", "h", "H" ];
/**
* Possible formats for the date
*/
export type secondType = (typeof secondtypes)[number];
export const isSecondType = (x: any): x is secondType => secondtypes.includes(x);
// ############################## [ Date Formats ] ############################## // ############################## [ Date Formats ] ##############################

View File

@ -1,6 +1,6 @@
import { dayDictionary } from "./Dictionaries/dateDictionary"; import { dayDictionary } from "./Dictionaries/dateDictionary";
import { monthDictionary } from "./Dictionaries/monthDictionary"; import { monthDictionary } from "./Dictionaries/monthDictionary";
import { commonDateFormats, dateType, isDateType, isMonthType, isYearType, monthType, yearType } from "./Types/formatTypes"; import { commonDateFormats, dateType, isDateType, isMonthType, isYearType, meridiemType, monthType, yearType } from "./Types/formatTypes";
/** /**
@ -74,6 +74,12 @@ export default class TymeJS {
// ############################## [ Time Formats ] ############################## // ############################## [ Time Formats ] ##############################
public getMeridiem(t: meridiemType): string {
throw new Error(`Invalid format for meridiem ${t}`);
}
// ############################## [ Date Formats ] ############################## // ############################## [ Date Formats ] ##############################

View File

@ -1,4 +1,4 @@
import TymeJS from "../src"; import TymeJS from "..";
let d: Date = new Date(); let d: Date = new Date();

View File

@ -1,4 +1,4 @@
import TymeJS from "../src"; import TymeJS from "..";
const a = new TymeJS(); const a = new TymeJS();

View File

@ -1,4 +1,4 @@
import TymeJS from "../src"; import TymeJS from "..";
for ( let i = 0; i < 12; i++ ) { for ( let i = 0; i < 12; i++ ) {