This package provides a set of functions for working with date and time in JavaScript using the Day.js library. It includes functions for parsing, formatting, and converting timestamps in various timezones.
You can install this package using npm or yarn:
npm install @bondsports/date-time
To use the functions provided by this package, import them as follows:
import {
parseUtc,
parseWithTimezone,
formatDateTime,
convertUtcTimestampToTimezone,
convertTimestampFromTimezoneToUtc,
convertUtcTimestampToLocalTime,
convertLocalTimestampToUtc,
convertTimestampFromTimezoneToTimezone,
} from '@bondsports/date-time';
- parseUtc(input: DateInput): dayjs.Dayjs: Parses a date in UTC mode.
- parseWithTimezone(input: DateInput, timezone: string): dayjs.Dayjs: Parses a date in the specified timezone.
- formatDateTime(input: dayjs.Dayjs, format?: DateTimeFormats, languageRegionCode?: LanguageRegionCodes): string: Formats a date as a string with optional format and language region.
- convertUtcTimestampToTimezone(input: DateInput, toTimezone: string, format?: DateTimeFormats, languageRegionCode?: LanguageRegionCodes): string: Converts a UTC timestamp to a specified timezone and formats it.
- convertTimestampFromTimezoneToUtc(input: DateInput, fromTimezone: string, format?: DateTimeFormats, languageRegionCode?: LanguageRegionCodes): string: Converts a timestamp from a specific timezone to UTC and formats it.
- convertUtcTimestampToLocalTime(input: DateInput, format?: DateTimeFormats, languageRegionCode?: LanguageRegionCodes): string: Converts a UTC timestamp to the local time of the system's timezone and formats it.
- convertLocalTimestampToUtc(input: DateInput, format?: DateTimeFormats, languageRegionCode?: LanguageRegionCodes): string: Converts a local timestamp to UTC and formats it.
- convertTimestampFromTimezoneToTimezone(input: DateInput, fromTimezone: string, toTimezone: string, format?: DateTimeFormats, languageRegionCode?: LanguageRegionCodes): string: Converts a timestamp from one timezone to another and formats it.
For detailed documentation of each function and its parameters, refer to the source code and JSDoc comments.