+ Parsing for Minutes
This commit is contained in:
parent
3cd34ad28a
commit
5b71124dde
13
src/index.ts
13
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 ] ##############################
|
||||
|
||||
|
|
Reference in New Issue