Skip to main content

@std/datetime@0.215.0

latest
Works with
It is unknown whether this package works with Node.js, Deno, Browsers, Cloudflare Workers, Bun
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score70%
Published2 years ago (0.215.0)

Functions

f
dayOfYear(date: Date): number

Returns the number of the day in the year in the local time zone.

f
dayOfYearUtc(date: Date): number

Returns the number of the day in the year in UTC time.

f
difference(
from: Date,
to: Date,
options?: DifferenceOptions
): DifferenceFormat

Returns the difference of the 2 given dates in the given units. If the units are omitted, it returns the difference in the all available units.

f
format(
date: Date,
formatString: string,
options?: FormatOptions
): string

Takes an input date and a formatString to format to a string.

f
isLeap(year: Date | number): boolean

Returns whether the given date or year (in number) is a leap year or not in the local time zone. based on: https://docs.microsoft.com/en-us/office/troubleshoot/excel/determine-a-leap-year

f
isUtcLeap(year: Date | number): boolean

Returns whether the given date or year (in number) is a leap year or not in UTC time. This always returns the same value regardless of the local timezone. based on: https://docs.microsoft.com/en-us/office/troubleshoot/excel/determine-a-leap-year

f
parse(
dateString: string,
formatString: string
): Date

Takes an input string and a formatString to parse to a date.

f
weekOfYear(date: Date): number

Returns the ISO week number of the provided date (1-53).

Interfaces

I

Options for format.

  • utc: boolean

    Whether returns the formatted date in UTC instead of local time.

Type Aliases

T
DifferenceFormat = Partial<Record<Unit, number>>

Return type for difference.

T
DifferenceOptions = { units?: Unit[]; }

Options for difference.

  • units: Unit[]
    No documentation available
T
Unit =
"milliseconds"
| "seconds"
| "minutes"
| "hours"
| "days"
| "weeks"
| "months"
| "quarters"
| "years"

Duration units for DifferenceFormat and DifferenceOptions.

Variables

v
DAY: number

The number of milliseconds in a day.

v
HOUR: number

The number of milliseconds in an hour.

v
MINUTE: number

The number of milliseconds in a minute.

v
SECOND: 1000

The number of milliseconds in a second.

v
WEEK: number

The number of milliseconds in a week.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/datetime

Import symbol

import * as mod from "@std/datetime";
or

Import directly with a jsr specifier

import * as mod from "jsr:@std/datetime";