Skip to main content
Home

latest

Minimalist date and time manipulation library

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
5 days ago (1.0.2)
class Time

This class provides static methods for working with dates and times.

Static Methods

add(
date: Date,
duration: Duration,
): Date

Adds a specified duration to a date

addMonths(
date: Date,
amount: number,
): Date

Adds a specified number of months to a date

addYears(
date: Date,
amount: number,
): Date

Adds a specified number of years to a date

after(
date1: Date,
date2: Date,
): boolean

Checks if a date is after another date

before(
date1: Date,
date2: Date,
): boolean

Checks if a date is before another date

compare(
date1: Date,
date2: Date,
): number

Compares two dates

days(amount: number): Duration

Returns duration in days

format(
date: Date,
layout?: string,
useUTC?: boolean,
): string

Formats a date to a string in the specified format

hours(amount: number): Duration

Returns duration in hours

minutes(amount: number): Duration

Returns duration in minutes

Returns the current date and time

parse(dateString: string): Date

Parses an ISO 8601 formatted string into a Date object

seconds(amount: number): Duration

Returns duration in seconds

truncate(
date: Date,
d: Duration,
): Date

Truncates the date down to the nearest multiple of duration since the zero time (epoch). If d <= 0, returns the original date (copy) unchanged.

weeks(amount: number): Duration

Returns duration in weeks

New Ticket: 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:@i9si-sistemas/time

Import symbol

import { Time } from "@i9si-sistemas/time";
or

Import directly with a jsr specifier

import { Time } from "jsr:@i9si-sistemas/time";

Add Package

pnpm i jsr:@i9si-sistemas/time
or (using pnpm 10.8 or older)
pnpm dlx jsr add @i9si-sistemas/time

Import symbol

import { Time } from "@i9si-sistemas/time";

Add Package

yarn add jsr:@i9si-sistemas/time
or (using Yarn 4.8 or older)
yarn dlx jsr add @i9si-sistemas/time

Import symbol

import { Time } from "@i9si-sistemas/time";

Add Package

npx jsr add @i9si-sistemas/time

Import symbol

import { Time } from "@i9si-sistemas/time";

Add Package

bunx jsr add @i9si-sistemas/time

Import symbol

import { Time } from "@i9si-sistemas/time";