Skip to content

Commit

Permalink
Merge pull request #29 from sineverba/release-1.4.0
Browse files Browse the repository at this point in the history
Release 1.4.0
  • Loading branch information
sineverba committed Jan 15, 2023
2 parents cdd77d5 + 43436f5 commit 8b05dfc
Show file tree
Hide file tree
Showing 15 changed files with 4,086 additions and 2,288 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:

test:
docker:
- image: cimg/node:10.24.1
- image: cimg/node:18.12.0

steps:
- checkout
Expand Down
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,py}]
charset = utf-8

# Tab indentation (no size specified)
[Makefile]
indent_style = tab

# Indentation override for all JS
[*.js]
indent_style = space
indent_size = 2
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v10.24.1
v18.13.0
File renamed without changes.
10 changes: 5 additions & 5 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ blocks:
- name: Test
matrix:
- env_var: NODE_VERSION
values: [ "10", "12", "14", "16" ]
values: [ "12", "14", "16", "18" ]
commands:
- sem-version node $NODE_VERSION
- npm run test
Expand All @@ -52,15 +52,15 @@ blocks:
- name: Coverage
commands:
- export COVERALLS_REPO_TOKEN=$COVERALLS_NPM_PKG_DATE_CONVERT
- npm run cover
- npm run coverage
- cat coverage/lcov.info | node_modules/coveralls/bin/coveralls.js
- name: Sonarcloud
commands:
- npm run cover
- docker run --rm -e SONAR_HOST_URL="https://sonarcloud.io" -e SONAR_LOGIN=$SONAR_TOKEN -v "/home/semaphore/npm-pkg-date-convert:/usr/src" sonarsource/sonar-scanner-cli:4.6
- npm run coverage
- docker run --rm -e SONAR_HOST_URL="https://sonarcloud.io" -e SONAR_LOGIN=$SONAR_TOKEN -v "/home/semaphore/npm-pkg-date-convert:/usr/src" sonarsource/sonar-scanner-cli:4.8.0

promotions:
- name: Deploy
pipeline_file: deploy.yml
pipeline_file: build-deploy.yml
auto_promote:
when: "tag =~ '.*'"
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# 1.3.0
# 1.4.0
+ Handle custom human date format
+ Upgrade dependencies

## 1.3.0
+ Upgrade dependencies
+ Add custom format

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2020 - 2022 sineverba
Copyright (c) 2020 - 2023 sineverba

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
include .env

SONARSCANNER_VERSION=4.8.0

sonar:
docker-compose up sonarscanner
docker run --rm -it \
--name sonarscanner \
-v $(PWD):/usr/src \
-e SONAR_HOST_URL=$(SONAR_HOST_URL) \
-e SONAR_LOGIN=$(SONAR_LOGIN) \
sonarsource/sonar-scanner-cli:$(SONARSCANNER_VERSION)

upgrade:
npx ncu -u
npm install
npm audit fix
npx browserslist@latest --update-db
npm audit fix
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,15 @@ console.log(humanDate); // returns 02/01/2020
var humanDate = fromIsoToHuman("20200102", "AAAA-MM-DD");
console.log(humanDate); // returns 2020-01-02

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

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

## Tests

`npm run test` for simple test

`npm run cover` for coverage

### SonarQube (local Docker)
+ Copy `.env.bak` in `.env`
+ Spin images `docker-compose up -d`
+ Create a new project inside Sonarqube and grab the token
+ Replace the token in the ENV var of `docker-compose.yml` file
+ Stop with `docker-compose stop` and restart with `docker-compose up -d`
+ Next spin with `make sonar`
`npm run coverage` for coverage
31 changes: 0 additions & 31 deletions docker-compose.yml

This file was deleted.

43 changes: 24 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
'use strict';
"use strict";

const moment = require("moment");

const ISO_FORMAT = 'YYYYMMDD';
const HUMAN_FORMAT = 'DD/MM/YYYY';
const ISO_FORMAT = "YYYYMMDD";
const HUMAN_FORMAT = "DD/MM/YYYY";

/**
*
*
* Return a ISO date (YYYYMMDD) to human format (DD/MM/YYYY)
*
*
* @param {*} isoDate
* @param {*} format
*/
function fromIsoToHuman (isoDate, format) {
const momentObj = moment(isoDate, ISO_FORMAT);
var currentFormat = HUMAN_FORMAT;
if (typeof format != "undefined") {
currentFormat = format;
}
return momentObj.format(currentFormat);
function fromIsoToHuman(isoDate, format) {
const momentObj = moment(isoDate, ISO_FORMAT);
var currentFormat = HUMAN_FORMAT;
if (typeof format != "undefined") {
currentFormat = format;
}
return momentObj.format(currentFormat);
}

/**
*
*
* Return a human date (DD/MM/YYYY) to ISO format
*
* @param {*} humanDate
*
* @param {*} humanDate
* @param {*} format the initial format of human date
*/
function fromHumanToIso (humanDate) {
const momentObj = moment(humanDate, HUMAN_FORMAT);
return momentObj.format(ISO_FORMAT);
function fromHumanToIso(humanDate, format) {
var currentFormat = HUMAN_FORMAT;
if (typeof format != "undefined") {
currentFormat = format;
}
const momentObj = moment(humanDate, currentFormat);
return momentObj.format(ISO_FORMAT);
}

module.exports.fromIsoToHuman = fromIsoToHuman;
module.exports.fromHumanToIso = fromHumanToIso;
module.exports.fromHumanToIso = fromHumanToIso;

0 comments on commit 8b05dfc

Please sign in to comment.