https://github.com/cityssm/modern-julian-date
Converts a regular JavaScript date to the modern Julian date format YYYYDDD.
https://github.com/cityssm/modern-julian-date
banking date-format javascript julian julian-date modern-julian-date yyddd yyyyddd
Last synced: 6 months ago
JSON representation
Converts a regular JavaScript date to the modern Julian date format YYYYDDD.
- Host: GitHub
- URL: https://github.com/cityssm/modern-julian-date
- Owner: cityssm
- License: mit
- Created: 2022-04-11T12:39:06.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-26T18:37:51.000Z (9 months ago)
- Last Synced: 2024-10-01T18:48:28.273Z (8 months ago)
- Topics: banking, date-format, javascript, julian, julian-date, modern-julian-date, yyddd, yyyyddd
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@cityssm/modern-julian-date
- Size: 193 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Modern Julian Date
[](https://www.npmjs.com/package/@cityssm/modern-julian-date)
[](https://app.deepsource.com/gh/cityssm/modern-julian-date/)
[](https://codeclimate.com/github/cityssm/modern-julian-date)
[](https://codecov.io/gh/cityssm/modern-julian-date)Converts a regular JavaScript date to the modern Julian date format YYYYDDD,
commonly seen in banking applications.## Getting Started
```sh
npm install @cityssm/modern-julian-date
```## Usage
```javascript
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)'
```