2.3.0 • Published 2 months ago

@sineverba/date-convert v2.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Date Convert

CI / CDStatus
NPMnpm version
Semaphore CIBuild Status
Circle CICircleCI
CoverallCoverage Status
SonarCloudQuality Gate Status

date-convert converts a ISO format YYYYMMDD string "19820405" to "05/04/1982" (where 05 is day and 04 is April). Use "/" as separator in output.

It works also with a date with other format. Simply, call the method fromIsoToHuman.

For example

const newDate = fromIsoToHuman("2024-01-31T15:27:42.427438", "DD/MM/YYYY");
console.log(newDate); // It prints 31/01/2024

Accepted INPUT

InputOutput
"20220323"23/03/2022
"2022-03-23"23/03/2022
"2022-03-09T12:31:16.699904"09/03/2022

Installation

npm install @sineverba/date-convert

Usage

// Import module
import { fromHumanToIso, fromIsoToHuman } from "@sineverba/date-convert";
// Or
// var {fromIsoToHuman, fromHumanToIso} = require('@sineverba/date-convert');

const humanDate = fromIsoToHuman("20200102");
console.log(humanDate); // returns 02/01/2020

const humanDateWithFormat = fromIsoToHuman("20200102", "YYYY-MM-DD");
console.log(humanDateWithFormat); // returns 2020-01-02

const isoDate = fromHumanToIso("02/01/2020");
console.log(isoDate); // returns 20200102

const isoDateWithFormat = fromHumanToIso("2020-01-02", "YYYY-MM-DD");
console.log(isoDateWithFormat); // returns 20200102

Tests

npm run test for simple test

npm run coverage for coverage

2.3.0

2 months ago

2.2.0

5 months ago

2.1.0

10 months ago

2.0.0

1 year ago

1.4.0

1 year ago

1.2.0

2 years ago

1.3.0

2 years ago

1.1.0

2 years ago

1.0.0

3 years ago

0.2.0

3 years ago

0.1.0

4 years ago