ng-timespan
TypeScript icon, indicating that this package has built-in type declarations

1.3.2 • Public • Published

ng-timespan

codecov Build Status

Because there were just not a lot of good Typescript options out there for timespans. Intended to be used with Angular but can potentially be used for just about any JS/TS project.

Usage

Install from NPM

npm i ng-timespan --save

Import

import { Timespan } from 'ng-timespan'

Use

// Create a date
let date1 = new Date()

// Create a second date
let date2 = date1.setHours(date1.getHours() + 2)

// Create the Timespan
let timespan = TimeSpan.Subtract(date1, date2)

// Do stuff! :)
console.log(`Time till expiration: ${timespan.days} days, ${timespan.hours} hours, ${timespan.hours} minutes, ${timespan.seconds}`)
console.log(`Total Days: ${timespan.totalDays}`)
console.log(`Total Hours: ${timespan.totalHours}`)
console.log(`Total Minutes: ${timespan.totalMinutes}`)
console.log(`Total Seconds: ${timespan.totalSeconds}`)
console.log(`Total Milliseconds: ${timespan.totalMilliSeconds}`)

Contributing

  1. 🍴& ⬇️
  2. npm i
  3. Make a meaningful change
  4. npm run build to make sure everythng is working right
  5. Commit to your 🍴
  6. Open a PR explaining why the change is required.

Readme

Keywords

none

Package Sidebar

Install

npm i ng-timespan

Weekly Downloads

2

Version

1.3.2

License

MIT

Unpacked Size

34.7 kB

Total Files

6

Last publish

Collaborators

  • greenygh0st