fix(date): now supports date and time
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
import * as plugins from './smarttime.plugins';
|
||||
|
||||
export type TAvailableZone = 'Europe/Berlin';
|
||||
|
||||
export class ExtendedDate extends Date {
|
||||
public static fromEuropeanDate(europeanDate: string) {
|
||||
const dateArray = /(.*)\.(.*)\.(.*)/.exec(europeanDate);
|
||||
@ -12,6 +14,16 @@ export class ExtendedDate extends Date {
|
||||
return new ExtendedDate(unixMilli);
|
||||
}
|
||||
|
||||
/** */
|
||||
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 unixMilli = luxonDate.toMillis();
|
||||
return new ExtendedDate(unixMilli);
|
||||
}
|
||||
|
||||
constructor(unixMilli: number) {
|
||||
super(unixMilli);
|
||||
}
|
||||
|
Reference in New Issue
Block a user