https://github.com/timruffles/periods
https://github.com/timruffles/periods
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/timruffles/periods
- Owner: timruffles
- Created: 2015-01-21T10:16:30.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-21T10:46:59.000Z (about 11 years ago)
- Last Synced: 2025-08-09T13:16:34.262Z (8 months ago)
- Language: JavaScript
- Size: 117 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-micro-npm-packages-zh - periods
- fucking-awesome-micro-npm-packages - periods - Defined time-periods constants for Javascript, in milliseconds. (Modules / Date & Time)
- awesome-micro-npm-packages - periods - Defined time-periods constants for Javascript, in milliseconds. (Modules / Date & Time)
- awesome-micro-npm-packages - periods - Defined time-periods constants for Javascript, in milliseconds. (Modules / Date & Time)
README
# Periods
Defined time-periods constants for Javascript, in milliseconds. Exposed as functions to make mis-typing fail noisily, rather than manifesting as `NaN`s in your data.
```javascript
var periods = require("periods");
var twentyFourHoursLater = Date.now() + periods.day();
var week = periods.week;
var durations = [1,2,3];
var weekDurations = durations.map(week);
```
Works in browser too.
## Methods
Each method has a plural defined. e.g `seconds()`, `monthsRough()`
### `second(n = 1)`
n * 1000
### `minute(n = 1)`
n * 60 * second
### `hour(n = 1)`
n * 60 * minute
### `day(n = 1)`
n * 24 * hour
### `week(n = 1)`
n * 7 * day
### `monthRough(n = 1)`
n * 4.3 * week
### `yearRough(n = 1)`
n * 365.25 * day