Skip to content

isToday ​

Checks whether a Luxon DateTime falls on the same calendar day as another DateTime, or today when no comparison value is provided. Pass the optional comparison value in tests to avoid depending on the real clock.

Importing ​

ts
import { isToday } from '@almighty-shogun/utils';

Usage ​

ts
import { DateTime } from 'luxon';
import { isToday } from '@almighty-shogun/utils';

const shouldHighlight = isToday(DateTime.now());

// true

Parameters

dateTime: DateTime
Date to check.

today?: Undefinable<DateTime>
Comparison date.

Returns

true when both values share the same day.

Uses ​

Type signature ​

ts
declare function isToday(
    dateTime: DateTime,
    today?: Undefinable<DateTime>
): boolean;

All packages are released under the MIT License.