Files
projects-jenz/discord_verificiation/playtime-frontend/lib/dates.ts
T

15 lines
498 B
TypeScript

import { parseDbDateTime } from './timezone';
// Parses a MySQL DATETIME string correctly regardless of the Node
// process's own timezone — see lib/timezone.ts.
export function parseDbDate(s: string): Date {
return parseDbDateTime(s);
}
export function diffMinutes(startStr: string, endStr: string | null): number | null {
if (!endStr) return null;
const start = parseDbDate(startStr);
const end = parseDbDate(endStr);
return Math.round((end.getTime() - start.getTime()) / 60000);
}