Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/harvesthq/hour-parser
Parse user-provided timestamp input and get nice output
https://github.com/harvesthq/hour-parser
parser parsing time userinput
Last synced: 6 days ago
JSON representation
Parse user-provided timestamp input and get nice output
- Host: GitHub
- URL: https://github.com/harvesthq/hour-parser
- Owner: harvesthq
- License: mit
- Created: 2017-05-11T14:56:12.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-02-12T18:55:37.000Z (9 months ago)
- Last Synced: 2024-02-12T19:56:56.702Z (9 months ago)
- Topics: parser, parsing, time, userinput
- Language: TypeScript
- Homepage:
- Size: 513 KB
- Stars: 5
- Watchers: 23
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# The Harvest Hour Parser
Parse user-provided durations or timestamps (in decimal or hh:mm format) and get nice output in your JavaScript or TypeScript project.
## Installation
In your project's directory, run:
```
npm install git+https://github.com/harvesthq/hour-parser.git#v2.1.0
```## Usage
```javascript
import { toDecimal, toHHMM } from 'hour-parser'toHHMM('0.5') // 0:30
toHHMM('0:5') // 0:05
toHHMM('1.25') // 1:15
toHHMM('1,25') // 1:15
toHHMM('1.5+3') // 4:30
toHHMM('1:45+3') // 4:45toDecimal('0.5') // 0.50
toDecimal('0:5') // 0.08
toDecimal('1.25') // 1.25
toDecimal('1,25') // 1.25
toDecimal('1.5+3') // 4.50
toDecimal('1:45+3') // 4.75
```## Development
This project uses Typescript. Do not modify `index.js` or `index.d.ts` manually. Make all changes to `src/index.ts`.
Run `npm test` to make sure nothing broke. Run `npm run build` to export a new build.
## License
[MIT](https://choosealicense.com/licenses/mit/)