AW-3477 fmHasPackage check werkt niet correct voor vandaag

This commit is contained in:
Willem Dantuma
2022-02-02 18:33:05 +01:00
parent 66e492d2f8
commit b191751e02
3 changed files with 18 additions and 17 deletions

View File

@@ -51,7 +51,8 @@ export function getValidPackages(packageMap: IPackages): {[key: string]: IPackag
}
export function isValidPackage(pack: IPackage): boolean {
const today = new Date(new Date(Date.now()).toUTCString()).setHours(0, 0, 0, 0);
return pack !== null && new Date(pack.dataDate).getTime() <= today
&& (!pack.dataEndDate || new Date(pack.dataEndDate).getTime() >= today);
const now = new Date(Date.now());
const utcToday = Date.UTC(now.getUTCFullYear(),now.getUTCMonth(),now.getUTCDate());
return pack !== null && new Date(pack.dataDate).getTime() <= utcToday
&& (!pack.dataEndDate || new Date(pack.dataEndDate).getTime() >= utcToday);
}