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.
The API documentation can be found at https://tacticallimit.github.io/isodate-lite/
Use the npm
or yarn
package manager to install isodate-lite.
npm install isodate-lite
yarn install isodate-lite
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();
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.
Generated using TypeDoc