Socket
Socket
Sign inDemoInstall

gdate-julian

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gdate-julian - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

src/_make_julian_date.js

10

package.json
{
"name": "gdate-julian",
"version": "1.0.0",
"version": "1.0.1",
"description": "Converts date to and from julian days in gLib GDate style",
"main": "src/index.js",
"main": "./src/index.js",
"types": "./src/index.d.ts",
"scripts": {

@@ -45,2 +46,5 @@ "test": "jest"

],
"engines": {
"node": ">= 6"
},
"author": "George Kotchlamazashvili <georgedot@gmail.com>",

@@ -53,4 +57,4 @@ "license": "MIT",

"devDependencies": {
"jest": "^23.6.0"
"jest": "^25.1.0"
}
}

@@ -0,1 +1,4 @@

const mkJDate = require('./_make_julian_date')
const t = Math.trunc
const g_julian_days_to_date = (julian_days) => {

@@ -11,26 +14,15 @@ /* Formula taken from the Calendar FAQ; the formula was for the

const A = julian_days + 1721425 + 32045;
const B = Math.trunc(Math.trunc(4 * (A + 36524)) / 146097) - 1;
const C = A - Math.trunc(Math.trunc(146097 * B) / 4);
const D = Math.trunc(Math.trunc(4 * (C + 365)) / 1461) - 1;
const E = C - Math.trunc(Math.trunc(1461 * D) / 4);
const M = Math.trunc((Math.trunc(5 * (E - 1)) + 2) / 153);
const B = t(t(4 * (A + 36524)) / 146097) - 1;
const C = A - t(t(146097 * B) / 4);
const D = t(t(4 * (C + 365)) / 1461) - 1;
const E = C - t(t(1461 * D) / 4);
const M = t((t(5 * (E - 1)) + 2) / 153);
const m = M + 3 - Math.trunc(12 * Math.trunc(M / 10));
const day = E - Math.trunc((Math.trunc(153 * M) + 2) / 5);
const y = Math.trunc(100 * B) + D - 4800 + Math.trunc(M / 10);
const m = M + 3 - t(12 * t(M / 10));
const day = E - t((t(153 * M) + 2) / 5);
const y = t(100 * B) + D - 4800 + t(M / 10);
const dt = new Date
dt.setUTCFullYear(y)
dt.setUTCMonth(m - 1)
dt.setUTCDate(day)
//TODO: the hours part could be calculated based on the remaining fraction
dt.setUTCHours(12)
dt.setUTCMinutes(0)
dt.setUTCSeconds(0)
dt.setUTCMilliseconds(0)
return dt
return mkJDate(y, m - 1, day)
}
module.exports = g_julian_days_to_date
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc