parent
97aa3e2281
commit
48a6d18c24
|
@ -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 ] ##############################
|
||||
|
||||
// =-=-=-=-=-=-=-=-=-=-= [ 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 ] ##############################
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { dayDictionary } from "./Dictionaries/dateDictionary";
|
||||
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 ] ##############################
|
||||
|
||||
public getMeridiem(t: meridiemType): string {
|
||||
|
||||
|
||||
throw new Error(`Invalid format for meridiem ${t}`);
|
||||
}
|
||||
|
||||
|
||||
// ############################## [ Date Formats ] ##############################
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import TymeJS from "../src";
|
||||
import TymeJS from "..";
|
||||
|
||||
let d: Date = new Date();
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import TymeJS from "../src";
|
||||
import TymeJS from "..";
|
||||
|
||||
const a = new TymeJS();
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import TymeJS from "../src";
|
||||
import TymeJS from "..";
|
||||
|
||||
for ( let i = 0; i < 12; i++ ) {
|
||||
|
Reference in New Issue