Skip to content

jasonraimondi/date-duration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DateDuration

The DateDuration class represents a duration of time specified in milliseconds. It provides methods to calculate and retrieve information about the duration.

Deno Version Npmjs.org Version GitHub Workflow Status Test Coverage NPM Downloads

Install (npm)

pnpm add @jmondi/date-duration

Deno

import { DateDuration } from "https://deno.land/x/date_duration";

Usage

The class is based on the ms package.

const duration = new DateDuration("2d");

Access the properties and methods of the DateDuration instance:

console.log(duration.endDate);          // Get the end date as a JavaScript Date object
console.log(duration.endTimeMs);        // Get the end time in milliseconds
console.log(duration.endTimeSeconds);   // Get the end time in seconds (rounded up)
console.log(duration.seconds);          // Get the duration in seconds (rounded up)

You can also use the static method getDateEnd to get the end date directly without creating an instance:

const endDate = DateDuration.getDateEnd("1w");
console.log(endDate);  // Get the end date as a JavaScript Date object

About

The DateDuration class represents a duration of time specified in milliseconds. It provides methods to calculate and retrieve information about the duration.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published