Socket
Book a DemoInstallSign in
Socket

iso-time-parser

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iso-time-parser

ISO 8601 Time parser (not date, nor duration)

1.1.3
latest
Source
npmnpm
Version published
Weekly downloads
6
100%
Maintainers
1
Weekly downloads
 
Created
Source

iso-time-parser

ISO 8601 Time parser (not date, nor duration)

wakatime Maintainability Test Coverage Bubdle Size

Installation

npm i iso-time-parser

Usage/Example

Full Documentation

Example:

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

npm i

Build/bundle package

npm run build

Build docs

npx typedoc src/index.ts

Bump version

npm version {major, minor, patch}

Publish

npm publish --access public

Keywords

ISO 8601

FAQs

Package last updated on 29 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.