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

NameTypeDescription
dateTimeDateTimeDate to check.
todayDateTimeOptional comparison date.

Returns

true when both values share the same day.

Type signature

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

All packages are released under the MIT License.