Skip to main content
Module

x/complaindate/mod.ts

JavaScript date-time utilities that keep timezones on the surface
Latest
import * as mod from "https://deno.land/x/complaindate@v1.0.1/mod.ts";

ComPlainDate

Date-time utilities that keep timezones on the surface.

Objects

The ComPlainDate interface describes plain-date objects that can be created with the PlainDate factory.

The ComPlainTime interface describes wall-time objects that can be created with the PlainTime factory.

Objects extended for convenience

Note: The extended objects are not tree-shakable, so using them will increase your bundle size... a lot. They are meant for use in backend code only — always use the main objects with utility functions in frontend code!

An extended type of plain-date object is described by the ExtendedPlainDate interface. Those objects are created with the ExPlainDate factory, which also implements the optional functions of the PlainDateFactory interface.

Utility functions

Parsing strings into objects

Splitting native JS Date objects into separate plain-date & plain-time objects

Generating a new plain-date object from an existing one

Also see pipePlainDate and related type PlainDateMapFn that are useful when implementing your own plain-date mapper functions.

Making user interface strings

Getting information about a plain-date object

Comparing plain-date objects

Creating native JS Date objects from plain-date & plain-time objects

Generating a new native JS Date object from an existing one

Comparing native JS Date objects

Working with timezone names

Variables

5

365

366

7

24

Month (1-12)

Milliseconds in an hour

Milliseconds in a minute

Milliseconds in a second

Quarter of year (1-4)

ISO weekday number (1-7) starting with Monday

Functions

Get a function curried with a number of business days to add to its plain-date arguments.

Get a function curried with a number of days to add to its plain-date arguments.

Get a function curried with a number of months to add to its plain-date arguments.

Get a function curried with a number of quarters to add to its plain-date arguments.

Get a function curried with a time duration to add to its native JS Date arguments.

Get a function curried with a number of years to add to its plain-date arguments.

Get a function curried with a timezone, to create native JS Date objects from date-time objects interpreted in the timezone.

Create a native JS Date object from a date-time interpreted in the system's local timezone.

Create a native JS Date object from a date-time interpreted in UTC.

Get the number of days in the month for a given date.

Get the number of days in the year of a given date.

Get a function curried with a plain-date, from which to get the number of crossings into non-weekend days between it and other plain-dates.

Get a function curried with a plain-date, from which to get the number of crossings into days between it and other plain-dates.

Get a function curried with a native JS Date, from which to get the number of milliseconds between it and other JS Date objects.

Get a function curried with a plain-date, from which to get the number of crossings over months between it and other plain-dates.

Get a function curried with a plain-date, from which to get the number of crossings over quarters between it and other plain-dates.

Get a function curried with a date, from which to get the number of crossings over years between it and other dates.

Factory function for making extended plain-date objects with extra properties and convenience methods.

Get a function curried with a weekday to jump to from its plain-date arguments.

Format a string suitable for HTML datetime-local inputs from a date-time object.

Curry a function to get localized strings of its JS Date arguments.

Curry a function to get localized strings of its plain-date arguments.

Curry a function to get localized strings of its plain-time arguments.

Format a timezone for display to a user.

Check if a plain-date is within Monday to Friday.

Check if a date is the first day of its month.

Check if a date is the first day of its year.

Check if a date is the last day of its month.

Check if a date is the last day of its year.

Check if a date is in a leap year.

Check if a string is a valid timezone in the system.

Check if a plain-date is a Saturday or Sunday.

Get the name of the system timezone, and fallback to "UTC" if the system doesn't expose a named timezone.

Get the day of the year for a plain-date.

Create a new plain-date object from an ISO date string.

Create a new plain-time object from an ISO time string.

Extract a valid timezone name from a string.

Get a function curried with a pipeline of functions to apply to its plain-date arguments, from left to right.

Factory function for making basic plain-date objects with minimal properties.

Factory function for making basic plain-time objects with minimal properties.

Get the quarter of the year for a plain-date.

Get a valid timezone name, adapted for the current user.

Clean up a timezone string, removing some common user typos and converting whitespace to underscore.

Get a function curried with a timezone, to split native JS Date objects into separate plain-date and plain-time parts.

Split native JS Date objects into separate plain-date and plain-time parts in the system's local timezone.

Split native JS Date objects into separate plain-date and plain-time parts in UTC.

Jump to the Monday of a plain-date's week.

Jump to the first day of a plain-date's month.

Jump to the first day of a plain-date's quarter.

Jump to the Saturday of a plain-date's week.

Jump to January 1 of a plain-date's year.

Get a function curried with a time duration to subtract from its native JS Date arguments.

Get all canonical timezones that are supported by the browser or runtime, or an empty array if the list is not available.

Get the ISO weekday number (1-7) starting with Monday from a plain-date.

Interfaces

Describes a basic plain-date object with minimal properties.

Describes a basic time-of-day object with minimal properties.

Describes an extended plain-date object with extra properties and convenience methods for common operations, of which many are chainable.

Describes a factory function that creates plain-date objects.

Describes a factory function that creates plain-time objects.

Type Aliases

Month (1-12)

Describes a function taking a plain-date object and returning the same.

Quarter of year (1-4)

ISO weekday number (1-7) starting with Monday