fix(ExtendedDate): now respects single digit dates
This commit is contained in:
parent
57fbdb4a70
commit
f0a5e18335
@ -15,11 +15,22 @@ export class ExtendedDate extends Date {
|
||||
}
|
||||
|
||||
/** */
|
||||
public static fromEuropeanDateAndTime(europeanDateArg: string, timeArg: string, zoneArg: TAvailableZone) {
|
||||
public static fromEuropeanDateAndTime(
|
||||
europeanDateArg: string,
|
||||
timeArg: string,
|
||||
zoneArg: TAvailableZone
|
||||
) {
|
||||
const dateArray = /(.*)\.(.*)\.(.*)/.exec(europeanDateArg);
|
||||
const luxonDate = plugins.luxon.DateTime.fromISO(`${dateArray[3]}-${dateArray[2]}-${dateArray[1]}T${timeArg}`, {
|
||||
zone: zoneArg
|
||||
});
|
||||
const sliceDate = (dateString: string) => {
|
||||
return `0${dateString}`.slice(-2);
|
||||
};
|
||||
const dateTimeString = `${dateArray[3]}-${sliceDate(dateArray[2])}-${sliceDate(dateArray[1])}T${timeArg}`;
|
||||
const luxonDate = plugins.luxon.DateTime.fromISO(
|
||||
dateTimeString,
|
||||
{
|
||||
zone: zoneArg
|
||||
}
|
||||
);
|
||||
const unixMilli = luxonDate.toMillis();
|
||||
return new ExtendedDate(unixMilli);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user