https://github.com/mathix420/iso-time-parser
ISO 8601 Time parser (not date, nor duration)
https://github.com/mathix420/iso-time-parser
Last synced: 19 days ago
JSON representation
ISO 8601 Time parser (not date, nor duration)
- Host: GitHub
- URL: https://github.com/mathix420/iso-time-parser
- Owner: mathix420
- License: apache-2.0
- Created: 2023-08-28T09:58:18.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-08-29T16:58:56.000Z (almost 3 years ago)
- Last Synced: 2025-07-09T02:44:53.421Z (11 months ago)
- Language: TypeScript
- Homepage: https://mathix420.github.io/iso-time-parser/
- Size: 175 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# iso-time-parser
[ISO 8601](https://www.wikiwand.com/fr/ISO_8601) Time parser (not date, nor duration)
[](https://wakatime.com/badge/github/mathix420/iso-time-parser) [](https://codeclimate.com/github/mathix420/iso-time-parser/maintainability) [](https://codeclimate.com/github/mathix420/iso-time-parser/test_coverage) [](https://bundlephobia.com/package/iso-time-parser)
## Installation
```bash
npm i iso-time-parser
```
## Usage/Example
[Full Documentation](https://mathix420.github.io/iso-time-parser/)
**Example:**
```typescript
import { parse, toLocalTime, toUTC } from 'iso-time-parser';
// Local time is Central European Summer Time (CEST) in this example
// Pulled from `new Date().getTimezoneOffset()`
parse('T11:22:33,4444Z').then(console.log);
// {
// hours: 11,
// minutes: 22,
// seconds: 33,
// fracSec: 4444,
// rawShift: { hours: 0, minutes: 0, sign: 1 },
// shiftInMinutes: 0
// }
parse('T11:22:33,4444Z').then(toLocalTime).then(console.log);
// {
// hours: 13,
// minutes: 22,
// seconds: 33,
// fracSec: 4444,
// rawShift: { hours: 2, minutes: 0, sign: -1 },
// shiftInMinutes: -120
// }
parse('T11:22:33,4444+03:45').then(toLocalTime).then(console.log);
// {
// hours: 9,
// minutes: 37,
// seconds: 33,
// fracSec: 4444,
// rawShift: { hours: 1, minutes: 45, sign: 1 },
// shiftInMinutes: 105
// }
parse('T11:22:33,4444+03:45').then(toUTC).then(console.log);
// {
// hours: 7,
// minutes: 37,
// seconds: 33,
// fracSec: 4444,
// rawShift: { hours: 3, minutes: 45, sign: 1 },
// shiftInMinutes: 225
// }
```
## Development
**Install deps**
```bash
npm i
```
**Build/bundle package**
```bash
npm run build
```
**Build docs**
```bash
npx typedoc src/index.ts
```
**Bump version**
```bash
npm version {major, minor, patch}
```
**Publish**
```bash
npm publish --access public
```