From 5b71124ddee564e518287c9b6a76ea08c676c9b4 Mon Sep 17 00:00:00 2001 From: Kato Twofold Date: Sat, 7 May 2022 14:26:05 +0300 Subject: [PATCH] + Parsing for Minutes --- src/index.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 76a74d9..97f3f21 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import { dayDictionary } from "./Dictionaries/dateDictionary"; import { monthDictionary } from "./Dictionaries/monthDictionary"; -import { commonDateFormats, dateType, hourType, isDateType, isHourType, isMeridiemType, isMonthType, isYearType, meridiemType, monthType, yearType } from "./Types/formatTypes"; +import { commonDateFormats, dateType, hourType, isDateType, isHourType, isMeridiemType, isMinuteType, isMonthType, isYearType, meridiemType, minuteType, monthType, yearType } from "./Types/formatTypes"; /** @@ -68,6 +68,8 @@ export default class TymeJS { formattedDate += this.getMeridiem(char); else if ( isHourType(char) ) formattedDate += this.getHour(char); + else if ( isMinuteType(char) ) + formattedDate += this.getMinutes(char); else { // Just append the char to the result formattedDate += char; @@ -116,6 +118,15 @@ export default class TymeJS { throw new Error(`Invalid format for Hour ${t}`); } + public getMinutes(t: minuteType ): string { + + if ( t === "i" ) { + return String(this.ts.getMinutes()).padStart(2, "0"); + } + + throw new Error(`Invalid format for Minute ${t}`); + } + // ############################## [ Date Formats ] ##############################