@tactical/isodate-lite
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

isodate-lite

Build dependencies Status Known Vulnerabilities Code Style: Google License: Apache-2.0 Documentation: Provided

ISO Date Lite is a node/typescript library for converting object values between ISO8601 date strings and native javascript date objects.

It was originally written as part of another project to cope with the @aws-sdk/util-dynamodb DynamoDB limitations while storing dates.

Documentation

The API documentation can be found at https://tacticallimit.github.io/isodate-lite/

Installation

Use the npm or yarn package manager to install isodate-lite.

npm install @tactical/isodate-lite
yarn add isodate-lite

Usage

import {convertDatesToISOStrings, convertISOStringsToDates} from 'isodate-lite';

const exampleDateObject = {
  name: 'Eris',
  age: 23,
  weapons: ['kallisti'],
  runDate: new Date(),
};

const exampleISOStringObject = {
  name: 'Bob',
  age: 42,
  weapons: ['pipe'],
  runDate: '2021-02-14T09:02:10.232Z',
};

function main() {
  const toStringExample = convertDatesToISOStrings(exampleDateObject);
  console.log('To string example:', toStringExample);
  const toDateExample = convertISOStringsToDates(exampleISOStringObject);
  console.log('To date example:', toDateExample);
}

main();

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

Apache-2.0

/@tactical/isodate-lite/

    Package Sidebar

    Install

    npm i @tactical/isodate-lite

    Weekly Downloads

    2

    Version

    1.0.0

    License

    Apache-2.0

    Unpacked Size

    19.3 kB

    Total Files

    7

    Last publish

    Collaborators

    • alchemycs