https://github.com/oeo/english-secs
https://github.com/oeo/english-secs
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/oeo/english-secs
- Owner: oeo
- Created: 2024-10-23T21:07:18.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-10-23T21:31:44.000Z (7 months ago)
- Last Synced: 2025-04-13T05:09:43.510Z (about 1 month ago)
- Language: CoffeeScript
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README

# english-secs
convert english time expressions to seconds or milliseconds. zero runtime dependencies.
## install
```bash
npm install english-secs --save
```## usage
```javascript
const etime = require('english-secs');console.log(etime('1 hour')); // 3600
console.log(etime('2 days 12 hours')); // 216000
console.log(etime('1 month', {milliseconds: true})); // 2678400000
```## api
`etime(input, options)`
- `input`: string or number. if number, returns input unchanged.
- `options`: object (optional)
- `milliseconds`: boolean. if true, returns milliseconds instead of seconds.
- `customUnits`: object. custom unit definitions.
- `customSingularUnits`: array. custom singular unit names.## features
- zero runtime dependencies
- lightweight and fast
- supports a wide range of time units and formats## development
- `yarn install`: install dependencies
- `yarn test`: run tests
- `yarn build`: compile coffeescript to javascript## license
mit