@sineverba/years-interval

Get an interval of years, useful for copyright notes

Usage no npm install needed!

<script type="module">
  import sineverbaYearsInterval from 'https://cdn.skypack.dev/@sineverba/years-interval';
</script>

README

Years Interval

CI / CD Status
NPM npm version
Semaphore CI Build Status
Circle CI CircleCI
Coverall Coverage Status
SonarCloud Quality Gate Status

years interval returns current year or a string made by a year start + current year.

Useful to use in copyright section ("Copyright 2018-2020 by Acme INC").

"2018-2020" in previous example is string returned.

Installation

npm install @sineverba/years-interval

Usage

(In following examples current year is assumed as 2020)

var interval = require('@sineverba/years-interval');
// Or...
// import interval from '@sineverba/years-interval'

var yearInterval = interval("2020");
console.log(yearInterval); // returns 2020
var newYearInterval = interval("2018");
console.log(newYearInterval); // returns 2018-2020
// on next year...
console.log(yearInterval); // returns 2020-2021
console.log(newYearInterval); // returns 2018-2021

Tests

npm test for simple test

npm cover for coverage