+ Parsing for Minutes

This commit is contained in:
Daniel Legt 2022-05-07 14:26:05 +03:00
parent 3cd34ad28a
commit 5b71124dde
1 changed files with 12 additions and 1 deletions

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, 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); formattedDate += this.getMeridiem(char);
else if ( isHourType(char) ) else if ( isHourType(char) )
formattedDate += this.getHour(char); formattedDate += this.getHour(char);
else if ( isMinuteType(char) )
formattedDate += this.getMinutes(char);
else { else {
// Just append the char to the result // Just append the char to the result
formattedDate += char; formattedDate += char;
@ -116,6 +118,15 @@ export default class TymeJS {
throw new Error(`Invalid format for Hour ${t}`); 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 ] ############################## // ############################## [ Date Formats ] ##############################