Socket
Socket
Sign inDemoInstall

bikram-sambat

Package Overview
Dependencies
1
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.3.7

6

package.json
{
"name": "bikram-sambat",
"version": "1.0.0",
"description": "JS utilities for converting between the Nepali Bikram Sambat (Vikram Samvat) and Gregorian (standard European) calendars.",

@@ -37,3 +36,4 @@ "main": "src/index.js",

"eurodigit": "^2.1.1"
}
}
},
"version": "1.3.7"
}
var toDevanagari = require('eurodigit/src/to_devanagari');
var MS_PER_DAY = 86400000;
// We have defined our own Epoch for Bikram Sambat: 1-1-2007 BS / 13-4-1950 AD
var BS_EPOCH_TS = -622359900000; // = Date.parse('1950-4-13')
var BS_YEAR_ZERO = 2007;
// TODO this would be stored more efficiently converted to a string using

@@ -25,11 +31,6 @@ // String.fromCharCode.apply(String, ENCODED_MONTH_LENGTHS), and extracted using

/**
* Magic numbers:
* 86400000 <- the number of miliseconds in a day
* 2007 <- The year (BS) whose first day is our Bikram Sambat Epoch (BSE)
* -622359900000 <- Date.parse('1950-4-13') = unix timestamp of BSE
*/
function toBik(greg) {
var m, dM, year = 2007,
days = Math.floor((Date.parse(greg) + 622359900000) / 86400000) + 1;
// TODO do not use Date.parse(), as per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse
var m, dM, year = BS_YEAR_ZERO,
days = Math.floor((Date.parse(greg) - BS_EPOCH_TS) / MS_PER_DAY) + 1;

@@ -62,2 +63,26 @@ while(days > 0) {

function toGreg(year, month, day) {
var timestamp = BS_EPOCH_TS;
while(year >= BS_YEAR_ZERO) {
while(month >= 1) {
while(day >= 1) {
timestamp += MS_PER_DAY;
--day;
}
--month;
day = daysInMonth(year, month, day);
}
--year;
month = 12;
day = daysInMonth(year, month, day);
}
var d = new Date(timestamp);
return {
year: d.getUTCFullYear(),
month: 1+d.getUTCMonth(),
day: d.getUTCDate()
};
}
module.exports = {

@@ -67,3 +92,4 @@ daysInMonth: daysInMonth,

toBik_euro: toBik_euro,
toBik_text: toBik_text
toBik_text: toBik_text,
toGreg: toGreg
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc