isodate-lite

A lightweight tool to convert object value between date objects and ISO8601 strings. Useful when storing objects in AWS DynamoDB.

Usage no npm install needed!

<script type="module">
  import isodateLite from 'https://cdn.skypack.dev/isodate-lite';
</script>

README

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 coverting 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 isodate-lite
yarn install 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