Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bikram-sambat-bootstrap

Package Overview
Dependencies
Maintainers
11
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bikram-sambat-bootstrap - npm Package Compare versions

Comparing version 1.5.0 to 1.6.0

239

dist/bikram-sambat-bs.js

@@ -1,2 +0,108 @@

(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
var toDevanagari = require('eurodigit/src/to_non_euro').devanagari;
var MS_PER_DAY = 86400000;
var MONTH_NAMES = ['बैशाख', 'जेठ', 'असार', 'साउन', 'भदौ', 'असोज', 'कार्तिक', 'मंसिर', 'पौष', 'माघ', 'फाल्गुन', 'चैत'];
// ------ TO UPDATE THESE HARDCODED VALUES USE /scripts/encode-days-in-month.js
// We have defined our own Epoch for Bikram Sambat: 1970-1-1 BS or 1913-4-13 AD
var BS_EPOCH_TS = -1789990200000; // = Date.parse('1913-4-13')
var BS_YEAR_ZERO = 1970;
var ENCODED_MONTH_LENGTHS = [
5315258,5314490,9459438,8673005,5315258,5315066,9459438,8673005,5315258,5314298,9459438,5327594,5315258,5314298,9459438,5327594,5315258,5314286,9459438,5315306,5315258,5314286,8673006,5315306,5315258,5265134,8673006,5315258,5315258,9459438,8673005,5315258,5314298,9459438,8673005,5315258,5314298,9459438,8473322,5315258,5314298,9459438,5327594,5315258,5314298,9459438,5327594,5315258,5314286,8673006,5315306,5315258,5265134,8673006,5315306,5315258,9459438,8673005,5315258,5314490,9459438,8673005,5315258,5314298,9459438,8473325,5315258,5314298,9459438,5327594,5315258,5314298,9459438,5327594,5315258,5314286,9459438,5315306,5315258,5265134,8673006,5315306,5315258,5265134,8673006,5315258,5314490,9459438,8673005,5315258,5314298,9459438,8669933,5315258,5314298,9459438,8473322,5315258,5314298,9459438,5327594,5315258,5314286,9459438,5315306,5315258,5265134,8673006,5315306,5315258,5265134,5527290,5527277,5527226,5527226,5528046,5527277,5528250,5528057,5527277,5527277
];
// TODO ENCODED_MONTH_LENGTHS would be stored more efficiently converted to a string using
// String.fromCharCode.apply(String, ENCODED_MONTH_LENGTHS), and extracted using
// ENC_MTH.charCodeAt(...). However, JS seems to do something weird with the
// top bits.
/**
* Magic numbers:
* BS_YEAR_ZERO <- the first year (BS) encoded in ENCODED_MONTH_LENGTHS
* month #5 <- this is the only month which has a day variation of more than 1
* & 3 <- this is a 2 bit mask, i.e. 0...011
*/
function daysInMonth(year, month) {
if(month < 1 || month > 12) throw new Error('Invalid month value ' + month);
var delta = ENCODED_MONTH_LENGTHS[year - BS_YEAR_ZERO];
if(typeof delta === 'undefined') throw new Error('No data for year: ' + year + ' BS');
return 29 + ((delta >>>
(((month-1) << 1))) & 3);
}
function zPad(x) { return x > 9 ? x : '0' + x; }
function toBik(greg) {
// 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;
while(days > 0) {
for(m=1; m<=12; ++m) {
dM = daysInMonth(year, m);
if(days <= dM) return { year:year, month:m, day:days };
days -= dM;
}
++year;
}
throw new Error('Date outside supported range: ' + greg + ' AD');
}
function toBik_euro(greg) {
var d = toBik(greg);
return d.year + '-' + zPad(d.month) + '-' + zPad(d.day);
}
function toBik_dev(greg) {
return toDevanagari(toBik_euro(greg));
}
function toBik_text(greg) {
var d = toBik(greg);
return toDevanagari(d.day) + ' ' + MONTH_NAMES[d.month-1] + ' ' + toDevanagari(d.year);
}
function toGreg(year, month, day) {
// TODO month bounds-checking should be handled in daysInMonth()
if(month < 1) throw new Error('Invalid month value ' + month);
if(year < BS_YEAR_ZERO) throw new Error('Invalid year value ' + year);
if(day < 1 || day > daysInMonth(year, month)) throw new Error('Invalid day value', day);
var timestamp = BS_EPOCH_TS + (MS_PER_DAY * day);
month--;
while (year >= BS_YEAR_ZERO) {
while (month > 0) {
timestamp += (MS_PER_DAY * daysInMonth(year, month));
month--;
}
month = 12;
year--;
}
var d = new Date(timestamp);
return {
year: d.getUTCFullYear(),
month: 1+d.getUTCMonth(),
day: d.getUTCDate()
};
}
function toGreg_text(year, month, day) {
var d = toGreg(year, month, day);
return d.year + '-' + zPad(d.month) + '-' + zPad(d.day);
}
module.exports = {
daysInMonth: daysInMonth,
toBik: toBik,
toBik_dev: toBik_dev,
toBik_euro: toBik_euro,
toBik_text: toBik_text,
toGreg: toGreg,
toGreg_text: toGreg_text
};
},{"eurodigit/src/to_non_euro":5}],2:[function(require,module,exports){
"use strict";

@@ -9,3 +115,3 @@ module.exports = {

},{"./to_euro":2,"./to_int":3,"./to_non_euro":4}],2:[function(require,module,exports){
},{"./to_euro":3,"./to_int":4,"./to_non_euro":5}],3:[function(require,module,exports){
'use strict';

@@ -24,10 +130,10 @@

},{}],3:[function(require,module,exports){
},{}],4:[function(require,module,exports){
var to_euro = require('./to_euro');
module.exports = function(s) {
return Number.parseInt(to_euro(s));
return parseInt(to_euro(s), 10);
};
},{"./to_euro":2}],4:[function(require,module,exports){
},{"./to_euro":3}],5:[function(require,module,exports){
'use strict';

@@ -48,3 +154,3 @@

},{}],5:[function(require,module,exports){
},{}],6:[function(require,module,exports){
var bs = require('bikram-sambat');

@@ -73,3 +179,3 @@ var eurodig = require('eurodigit');

var $inputGroup = $this.parents('.bikram-sambat-input-group');
updateBackingDateInput($inputGroup, dateInputSelecter);
updateConvertedDate($inputGroup, dateInputSelecter);
})

@@ -85,3 +191,3 @@ ;

updateBackingDateInput($inputGroup, dateInputSelecter);
updateConvertedDate($inputGroup, dateInputSelecter);
});

@@ -100,3 +206,3 @@ }

function setDropdown($parent, name, val) {
var $input = $parent.find('[name='+name+']')
var $input = $parent.find('[name='+name+']');
$input.parents('.bikram-sambat-input-group')

@@ -107,5 +213,6 @@ .find('.dropdown-menu li a')

}
function updateBackingDateInput($inputGroup, dateInputSelecter) {
function updateConvertedDate($inputGroup, dateInputSelecter) {
var greg = getDate_greg_text($inputGroup);
if(greg) $(dateInputSelecter).val(greg);
$(dateInputSelecter).val(greg).trigger('change');
}

@@ -148,110 +255,2 @@

},{"bikram-sambat":7,"eurodigit":1}],6:[function(require,module,exports){
arguments[4][4][0].apply(exports,arguments)
},{"dup":4}],7:[function(require,module,exports){
var toDevanagari = require('eurodigit/src/to_non_euro').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
// String.fromCharCode.apply(String, ENCODED_MONTH_LENGTHS), and extracted using
// ENC_MTH.charCodeAt(...). However, JS seems to do something weird with the
// top bits.
var ENCODED_MONTH_LENGTHS = [
8673005,5315258,5314298,9459438,8673005,5315258,5314298,9459438,8473322,5315258,5314298,9459438,5327594,5315258,5314298,9459438,5327594,5315258,5314286,8673006,5315306,5315258,5265134,8673006,5315306,5315258,9459438,8673005,5315258,5314490,9459438,8673005,5315258,5314298,9459438,8473325,5315258,5314298,9459438,5327594,5315258,5314298,9459438,5327594,5315258,5314286,9459438,5315306,5315258,5265134,8673006,5315306,5315258,5265134,8673006,5315258,5314490,9459438,8673005,5315258,5314298,9459438,8669933,5315258,5314298,9459438,8473322,5315258,5314298,9459438,5327594,5315258,5314286,9459438,5315306,5315258,5265134,8673006,5315306,5315258,5265134,5527290,5527277,5527226,5527226,5528046,5527277,5528250,5528057,5527277,5527277
],
MONTH_NAMES = ['बैशाख', 'जेठ', 'असार', 'साउन', 'भदौ', 'असोज', 'कार्तिक', 'मंसिर', 'पौष', 'माघ', 'फाल्गुन', 'चैत'];
/**
* Magic numbers:
* 2000 <- the first year (BS) encoded in ENCODED_MONTH_LENGTHS
* month #5 <- this is the only month which has a day variation of more than 1
* & 3 <- this is a 2 bit mask, i.e. 0...011
*/
function daysInMonth(year, month) {
// TODO why does this accept 0?
if(month < 0 || month > 12) throw new Error('Invalid month value ' + month);
var delta = ENCODED_MONTH_LENGTHS[year - 2000];
if(typeof delta === 'undefined') throw new Error('No data for year: ' + year + ' BS');
return 29 + ((delta >>>
(((month-1) << 1))) & 3);
}
function zPad(x) { return x > 9 ? x : '0' + x; }
function toBik(greg) {
// 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;
while(days > 0) {
for(m=1; m<=12; ++m) {
dM = daysInMonth(year, m);
if(days <= dM) return { year:year, month:m, day:days };
days -= dM;
}
++year;
}
throw new Error('Date outside supported range: ' + greg + ' AD');
}
function toBik_euro(greg) {
var d = toBik(greg);
return d.year + '-' + zPad(d.month) + '-' + zPad(d.day);
}
function toBik_dev(greg) {
return toDevanagari(toBik_euro(greg));
}
function toBik_text(greg) {
var d = toBik(greg);
return toDevanagari(d.day) + ' ' + MONTH_NAMES[d.month-1] + ' ' + toDevanagari(d.year);
}
function toGreg(year, month, day) {
// TODO month bounds-checking should be handled in daysInMonth()
if(month < 1) throw new Error('Invalid month value ' + month);
if(year < BS_YEAR_ZERO) throw new Error('Invalid year value ' + year);
if(day < 1 || day > daysInMonth(year, month)) throw new Error('Invalid day value', day);
var timestamp = BS_EPOCH_TS;
while(year >= BS_YEAR_ZERO) {
while(month >= 1) {
while(--day >= 0) {
timestamp += MS_PER_DAY;
}
day = daysInMonth(year, --month);
}
day = daysInMonth(--year, month = 12);
}
var d = new Date(timestamp);
return {
year: d.getUTCFullYear(),
month: 1+d.getUTCMonth(),
day: d.getUTCDate()
};
}
function toGreg_text(year, month, day) {
var d = toGreg(year, month, day);
return d.year + '-' + zPad(d.month) + '-' + zPad(d.day);
}
module.exports = {
daysInMonth: daysInMonth,
toBik: toBik,
toBik_dev: toBik_dev,
toBik_euro: toBik_euro,
toBik_text: toBik_text,
toGreg: toGreg,
toGreg_text: toGreg_text
};
},{"eurodigit/src/to_non_euro":6}]},{},[5]);
},{"bikram-sambat":1,"eurodigit":2}]},{},[6]);
{
"name": "bikram-sambat-bootstrap",
"version": "1.5.0",
"version": "1.6.0",
"description": "bikram sambat datepicker for bootstrap",

@@ -27,5 +27,5 @@ "main": "src/bikram-sambat-bootstrap.js",

"dependencies": {
"bikram-sambat": "^1.6.0",
"bikram-sambat": "^1.7.0",
"eurodigit": "^3.1.1"
}
}

@@ -24,3 +24,3 @@ var bs = require('bikram-sambat');

var $inputGroup = $this.parents('.bikram-sambat-input-group');
updateBackingDateInput($inputGroup, dateInputSelecter);
updateConvertedDate($inputGroup, dateInputSelecter);
})

@@ -36,3 +36,3 @@ ;

updateBackingDateInput($inputGroup, dateInputSelecter);
updateConvertedDate($inputGroup, dateInputSelecter);
});

@@ -57,5 +57,6 @@ }

}
function updateBackingDateInput($inputGroup, dateInputSelecter) {
function updateConvertedDate($inputGroup, dateInputSelecter) {
var greg = getDate_greg_text($inputGroup);
if(greg) $(dateInputSelecter).val(greg).trigger('change');
$(dateInputSelecter).val(greg).trigger('change');
}

@@ -62,0 +63,0 @@

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