@cityssm/modern-julian-date
v1.0.1
Published
Converts a regular JavaScript date to the modern Julian date format YYYYDDD.
Downloads
556
Maintainers
Readme
Modern Julian Date
Converts a regular JavaScript date to the modern Julian date format YYYYDDD, commonly seen in banking applications.
Getting Started
npm install @cityssm/modern-julian-date
Usage
import {
fromModernJulianDate,
toModernJulianDate,
toShortModernJulianDate
} from "@cityssm/modern-julian-date";
/*
* toModernJulianDate()
* Returns date strings in YYYYDDD format.
*/
console.log( toModernJulianDate(new Date(2022, 1 - 1, 1)) );
// => '2022001'
console.log( toModernJulianDate(new Date(2022, 12 - 1, 31)) );
// => '2022365'
console.log( toModernJulianDate(new Date(2020, 12 - 1, 31)) );
// => '2020366'
/*
* toShortModernJulianDate()
* Returns date strings in YYDDD format.
*/
console.log( toShortModernJulianDate(new Date(2022, 1 - 1, 1)) );
// => '22001'
/*
* fromModernJulianDate()
* Returns Date objects.
*/
console.log( fromModernJulianDate('2020366') )
// => 'Thu Dec 31 2020 00:00:00 GMT-0500 (Eastern Standard Time)'