ng-timespan
v1.3.2
Published
A TS/JS implementation of Timespans
Downloads
33
Readme
ng-timespan
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
- 🍴& ⬇️
- npm i
- Make a meaningful change
- npm run build to make sure everythng is working right
- Commit to your 🍴
- Open a PR explaining why the change is required.