Skip to Content
⚠️Active Development Notice: TimeTiles is under active development. Information may be placeholder content or not up-to-date.

web


web / lib/utils/date

lib/utils/date

Provides utility functions for formatting and validating dates.

This module contains helpers to convert date strings or Date objects into consistent, human-readable formats for display in the user interface. It handles null or invalid date inputs gracefully and provides options for both long (date and time) and short (date only) formats.

Functions

isValidDate()

isValidDate(date): boolean

Check if a Date object is valid.

Parameters

date

Date

Date object to validate

Returns

boolean

True if the date is valid, false if invalid (NaN time)

Example

const date = new Date('invalid'); isValidDate(date); // Returns false const validDate = new Date('2024-01-15'); isValidDate(validDate); // Returns true

formatDate()

formatDate(date): string

Format a date string or Date object for display.

Parameters

date

undefined | null | string | Date

Returns

string


formatDateShort()

formatDateShort(date): string

Format a date for short display (just the date, no time).

Parameters

date

undefined | null | string | Date

Returns

string

Last updated on