All files / src/lib date.ts

100% Statements 5/5
100% Branches 4/4
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12        335x   22x   18x 18x    
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 Max Boksem. See NOTICE for additional terms under GPLv3 section 7.
 
/** The current Unix time in whole seconds, the unit EPG times use. */
export const nowSeconds = (): number => Math.floor(Date.now() / 1000);
 
export const parseDateMs = (value: string | null | undefined): number => {
	// Stryker disable next-line StringLiteral: Date.parse gives NaN for both "" and the text Stryker puts in, so this returns 0 either way.
	const ms = Date.parse(value ?? "");
	return isNaN(ms) ? 0 : ms;
};