Skip to main content
Module

x/date_only/mod.ts>DateOnly

A micro library for actual "dates", not "date times"
Latest
class DateOnly
import { DateOnly } from "https://deno.land/x/date_only@0.1.0/mod.ts";

A class to represent Dates and the interval of time they represent.

This allows easy and fast creation of an which has the properties .startEpoch and .endEpoch which allow you to check if a given epoch moment is within that date, before it, after it, etc.

New class instances can be created via new DateOnly(...), DateOnly.newOrUndefined(...), DateOnly.fromString(...), and DateOnly.fromStringOrUndefined(...).

Constructors

new
DateOnly(
y: number,
m: number,
d: number,
)

Properties

day: number
endEpoch: number

The inclusive epoch timestamp for when the day ended (i.e. last millisecond of the day)

month: number
startEpoch: number

The inclusive epoch timestamp for when the day started (i.e. first millisecond of the day)

timezoneShift: DateOnlyTimezone

See docs on DateOnlyTimezone for details

year: number

Methods

Returns 'YYYY-MM-DD'

Returns 'YYYY-MM-DD'

Returns 'YYYY-MM-DD'

Static Methods

Parse string via parseStringToDateComponents and then create new DateOnly

fromStringOrUndefined(s: string, tz?: DateOnlyTimezone): DateOnly | undefined

Same as .fromString, but returns undefined on failure instead of throwing DateOnlyError

newOrUndefined(
y: number,
m: number,
d: number,
): DateOnly | undefined

Same as constructor, but returns undefined on failure instead of throwing DateOnlyError