GithubHelp home page GithubHelp logo

sineverba / npm-pkg-date-convert Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 259 KB

Convert a date from / to ISO format YYYYMMDD to human readable format (DD/MM/YYYY)

License: MIT License

JavaScript 2.51% Makefile 6.52% Shell 1.43% TypeScript 79.95% Gherkin 9.59%

npm-pkg-date-convert's Introduction

Date Convert

CI / CD Status
NPM npm version
Semaphore CI Build Status
Circle CI CircleCI
Coverall Coverage Status
SonarCloud Quality 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

Input Output
"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

npm-pkg-date-convert's People

Contributors

sineverba avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.