/* tslint:disable */ import { DateTime } from 'luxon'; export function isSameOrAfter(time: DateTime, compareWith: DateTime, unit: 'hours' | 'minutes' = 'minutes'): boolean { if (unit === 'hours') { return time.hour >= compareWith.hour; } if (unit === 'minutes') { return time.hasSame(compareWith, unit) || time.valueOf() > compareWith.valueOf(); } } export function isSameOrBefore(time: DateTime, compareWith: DateTime, unit: 'hours' | 'minutes' = 'minutes'): boolean { if (unit === 'hours') { return time.hour <= compareWith.hour; } if (unit === 'minutes') { return time.hasSame(compareWith, unit) || time.valueOf() <= compareWith.valueOf(); } } export function isBetween(time: DateTime, before: DateTime, after: DateTime, unit: 'hours' | 'minutes' = 'minutes'): boolean { if (unit === 'hours') { return isSameOrBefore(time, after, unit) && isSameOrAfter(time, before, unit); } if (unit === 'minutes') { return isSameOrBefore(time, after) && isSameOrAfter(time, before); } } export function isDigit(e: KeyboardEvent) { // Allow: backspace, delete, tab, escape, enter if ([46, 8, 9, 27, 13].some(n => n === e.keyCode) || // Allow: Ctrl/cmd+A (e.keyCode == 65 && (e.ctrlKey === true || e.metaKey === true)) || // Allow: Ctrl/cmd+C (e.keyCode == 67 && (e.ctrlKey === true || e.metaKey === true)) || // Allow: Ctrl/cmd+X (e.keyCode == 88 && (e.ctrlKey === true || e.metaKey === true)) || // Allow: home, end, left, right, up, down (e.keyCode >= 35 && e.keyCode <= 40)) { return true; } return !((e.keyCode < 48 || e.keyCode > 57) && (e.keyCode < 96 || e.keyCode > 105)); }