import * as complaindate from "https://deno.land/x/complaindate@v0.7.2/mod.ts";
ComPlainDate
Date-time utilities that keeps timezones on the surface.
Main objects
The ComPlainDate interface describes plain-date objects, that can be created with the PlainDate factory, described by the PlainDateFactory interface.
The ComPlainTime interface describes wall-time objects, that can be created with the PlainTime factory, described by the PlainTimeFactory interface.
Extended objects
Note: These objects are not tree-shakable, so using them will increase your bundle size... a lot. Extended objects 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.
Utility functions
Parsing strings into objects
- parsePlainDate (extract plain-date from string)
- parsePlainTime (extract plain-time from string)
Splitting native JS Date
objects into separate plain-date & plain-time objects
- splitDateTime - requires a named timezone
- splitLocalDateTime
- splitUtcDateTime
Generating a new plain-date object from an existing one
- addBusinessDays
- addDays
- addMonths
- addQuarters
- addYears
- firstWeekDay
- startOfBusinessWeek
- startOfMonth
- startOfQuarter
- startOfWeekend
- startOfYear
Also see pipePlainDate and related type PlainDateMapFn that are useful when implementing your own plain-date mapper functions.
Making user interface strings
- formatPlainDate
- formatPlainTime
- formatInstant
- formatTimezone
- formatDatetimeLocal (for HTML datetime-local inputs)
Getting information about a plain-date object
- daysInMonth
- daysInYear
- isBusinessDay and inverse isWeekendDay
- isFirstDayOfMonth and isLastDayOfMonth
- isFirstDayOfYear and isLastDayOfYear
- isLeapYear
- ordinal (day of the year)
- quarter
- weekDayNumber
Comparing plain-date objects
Creating native JS Date
objects from plain-date & plain-time objects
- createInstant - requires a named timezone
- createLocalInstant
- createUtcInstant
Generating a new native JS Date
object from an existing one
Comparing native JS Date
objects
Working with timezone names
- safeTimezone - falls back to system timezone
- localTimezone (operating system timezone)
- supportedCanonicalTimezones
- isTimezone
- sanitizeTimezone (clean up timezone name)
- parseTimezone (extract timezone name from string) - throws error on failure
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 | |
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 | |
Create a native JS | |
Create a native JS | |
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 | |
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 | |
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 | |
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 | |
Split native JS | |
Split native JS | |
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 | |
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 |