Socket
Socket
Sign inDemoInstall

bootstrap-datetimepicker

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bootstrap-datetimepicker - npm Package Compare versions

Comparing version 0.0.5 to 0.0.7

2

package.json
{
"name": "bootstrap-datetimepicker",
"version": "0.0.5",
"version": "0.0.7",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

@@ -119,3 +119,3 @@ /**

type: 'show',
date: this.date
date: this._date
});

@@ -143,3 +143,3 @@ this._attachDatePickerGlobalEvents();

type: 'hide',
date: this.date
date: this._date
});

@@ -150,12 +150,13 @@ this._detachDatePickerGlobalEvents();

set: function() {
var formated = this.formatDate(this.date);
var formatted = '';
if (!this._unset) formatted = this.formatDate(this._date);
if (!this.isInput) {
if (this.component){
var input = this.$element.find('input');
input.val(formated);
input.val(formatted);
this._resetMaskPos(input);
}
this.$element.data('date', formated);
this.$element.data('date', formatted);
} else {
this.$element.val(formated);
this.$element.val(formatted);
this._resetMaskPos(this.$element);

@@ -166,9 +167,14 @@ }

setValue: function(newDate) {
if (!newDate) {
this._unset = true;
} else {
this._unset = false;
}
if (typeof newDate === 'string') {
this.date = this.parseDate(newDate);
this._date = this.parseDate(newDate);
} else {
this.date = new Date(newDate);
this._date = new Date(newDate);
}
this.set();
this.viewDate = UTCDate(this.date.getUTCFullYear(), this.date.getUTCMonth(), 1, 0, 0, 0, 0);
this.viewDate = UTCDate(this._date.getUTCFullYear(), this._date.getUTCMonth(), 1, 0, 0, 0, 0);
this.fillDate();

@@ -179,11 +185,14 @@ this.fillTime();

getDate: function() {
return new Date(this.date.valueOf());
if (this._unset) return null;
return new Date(this._date.valueOf());
},
setDate: function(date) {
this.setValue(date.valueOf());
if (!date) this.setValue(null);
else this.setValue(date.valueOf());
},
getLocalDate: function() {
var d = this.date;
if (this._unset) return null;
var d = this._date;
return new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(),

@@ -194,4 +203,12 @@ d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds());

setLocalDate: function(localDate) {
this.setValue(Date.UTC(localDate.getFullYear(), localDate.getMonth(), localDate.getDate(),
localDate.getHours(), localDate.getMinutes(), localDate.getSeconds(), localDate.getMilliseconds()));
if (!localDate) this.setValue(null);
else
this.setValue(Date.UTC(
localDate.getFullYear(),
localDate.getMonth(),
localDate.getDate(),
localDate.getHours(),
localDate.getMinutes(),
localDate.getSeconds(),
localDate.getMilliseconds()));
},

@@ -207,2 +224,10 @@

notifyChange: function(){
this.$element.trigger({
type: 'changeDate',
date: this.getDate(),
localDate: this.getLocalDate()
});
},
update: function(newDate){

@@ -218,3 +243,3 @@ var dateStr = newDate;

var tmp = new Date()
this.date = UTCDate(tmp.getFullYear(),
this._date = UTCDate(tmp.getFullYear(),
tmp.getMonth(),

@@ -227,6 +252,6 @@ tmp.getDate(),

} else {
this.date = this.parseDate(dateStr);
this._date = this.parseDate(dateStr);
}
}
this.viewDate = UTCDate(this.date.getUTCFullYear(), this.date.getUTCMonth(), 1, 0, 0, 0, 0);
this.viewDate = UTCDate(this._date.getUTCFullYear(), this._date.getUTCMonth(), 1, 0, 0, 0, 0);
this.fillDate();

@@ -259,5 +284,5 @@ this.fillTime();

var currentDate = UTCDate(
this.date.getUTCFullYear(),
this.date.getUTCMonth(),
this.date.getUTCDate(),
this._date.getUTCFullYear(),
this._date.getUTCMonth(),
this._date.getUTCDate(),
0, 0, 0, 0

@@ -301,3 +326,3 @@ );

this.widget.find('.datepicker-days tbody').empty().append(html.join(''));
var currentYear = this.date.getUTCFullYear();
var currentYear = this._date.getUTCFullYear();

@@ -307,3 +332,3 @@ var months = this.widget.find('.datepicker-months').find(

if (currentYear === year) {
months.eq(this.date.getUTCMonth()).addClass('active');
months.eq(this._date.getUTCMonth()).addClass('active');
}

@@ -328,3 +353,3 @@

var html = '';
if (this.pick12HourFormat) {
if (this.options.pick12HourFormat) {
var current = 1;

@@ -392,3 +417,3 @@ for (var i = 0; i < 3; i += 1) {

fillTime: function() {
if (!this.date)
if (!this._date)
return;

@@ -398,3 +423,3 @@ var timeComponents = this.widget.find('.timepicker span[data-time-component]');

var is12HourFormat = this.options.pick12HourFormat;
var hour = this.date.getUTCHours();
var hour = this._date.getUTCHours();
var period = 'AM';

@@ -404,3 +429,3 @@ if (is12HourFormat) {

if (hour === 0) hour = 12;
else hour = hour % 12;
else if (hour != 12) hour = hour % 12;
this.widget.find(

@@ -410,4 +435,4 @@ '.timepicker [data-action=togglePeriod]').text(period);

hour = padLeft(hour.toString(), 2, '0');
var minute = padLeft(this.date.getUTCMinutes().toString(), 2, '0');
var second = padLeft(this.date.getUTCSeconds().toString(), 2, '0');
var minute = padLeft(this._date.getUTCMinutes().toString(), 2, '0');
var second = padLeft(this._date.getUTCSeconds().toString(), 2, '0');
timeComponents.filter('[data-time-component=hours]').text(hour);

@@ -450,16 +475,12 @@ timeComponents.filter('[data-time-component=minutes]').text(minute);

if (this.viewMode !== 0) {
this.date = UTCDate(
this._date = UTCDate(
this.viewDate.getUTCFullYear(),
this.viewDate.getUTCMonth(),
this.viewDate.getUTCDate(),
this.date.getUTCHours(),
this.date.getUTCMinutes(),
this.date.getUTCSeconds(),
this.date.getUTCMilliseconds()
this._date.getUTCHours(),
this._date.getUTCMinutes(),
this._date.getUTCSeconds(),
this._date.getUTCMilliseconds()
);
this.$element.trigger({
type: 'changeDate',
date: this.date,
viewMode: DPGlobal.modes[this.viewMode].clsName
});
this.notifyChange();
}

@@ -490,8 +511,8 @@ this.showMode(-1);

}
this.date = UTCDate(
this._date = UTCDate(
year, month, day,
this.date.getUTCHours(),
this.date.getUTCMinutes(),
this.date.getUTCSeconds(),
this.date.getUTCMilliseconds()
this._date.getUTCHours(),
this._date.getUTCMinutes(),
this._date.getUTCSeconds(),
this._date.getUTCMilliseconds()
);

@@ -502,7 +523,3 @@ this.viewDate = UTCDate(

this.set();
this.$element.trigger({
type: 'changeDate',
date: this.date,
viewMode: DPGlobal.modes[this.viewMode].clsName
});
this.notifyChange();
}

@@ -516,30 +533,30 @@ break;

incrementHours: function(e) {
this.date.setUTCHours(this.date.getUTCHours() + 1);
this._date.setUTCHours(this._date.getUTCHours() + 1);
},
incrementMinutes: function(e) {
this.date.setUTCMinutes(this.date.getUTCMinutes() + 1);
this._date.setUTCMinutes(this._date.getUTCMinutes() + 1);
},
incrementSeconds: function(e) {
this.date.setUTCSeconds(this.date.getUTCSeconds() + 1);
this._date.setUTCSeconds(this._date.getUTCSeconds() + 1);
},
decrementHours: function(e) {
this.date.setUTCHours(this.date.getUTCHours() - 1);
this._date.setUTCHours(this._date.getUTCHours() - 1);
},
decrementMinutes: function(e) {
this.date.setUTCMinutes(this.date.getUTCMinutes() - 1);
this._date.setUTCMinutes(this._date.getUTCMinutes() - 1);
},
decrementSeconds: function(e) {
this.date.setUTCSeconds(this.date.getUTCSeconds() - 1);
this._date.setUTCSeconds(this._date.getUTCSeconds() - 1);
},
togglePeriod: function(e) {
var hour = this.date.getUTCHours();
var hour = this._date.getUTCHours();
if (hour >= 12) hour -= 12;
else hour += 12;
this.date.setUTCHours(hour);
this._date.setUTCHours(hour);
},

@@ -571,3 +588,3 @@

if (this.options.pick12HourFormat) {
var current = this.date.getUTCHours();
var current = this._date.getUTCHours();
if (current >= 12) {

@@ -580,3 +597,3 @@ if (value != 12) value = (value + 12) % 24;

}
this.date.setUTCHours(value);
this._date.setUTCHours(value);
this.actions.showPicker.call(this);

@@ -588,3 +605,3 @@ },

var value = parseInt(tgt.text(), 10);
this.date.setUTCMinutes(value);
this._date.setUTCMinutes(value);
this.actions.showPicker.call(this);

@@ -596,3 +613,3 @@ },

var value = parseInt(tgt.text(), 10);
this.date.setUTCSeconds(value);
this._date.setUTCSeconds(value);
this.actions.showPicker.call(this);

@@ -605,3 +622,3 @@ }

e.preventDefault();
if (!this.date) this.date = UTCDate(1970, 0, 0, 0, 0, 0, 0);
if (!this._date) this._date = UTCDate(1970, 0, 0, 0, 0, 0, 0);
var action = $(e.currentTarget).data('action');

@@ -611,6 +628,3 @@ var rv = this.actions[action].apply(this, arguments);

this.fillTime();
this.$element.trigger({
type: 'changeDate',
date: this.date,
});
this.notifyChange();
return rv;

@@ -687,20 +701,15 @@ },

this.update();
this.$element.trigger({
type: 'changeDate',
date: this.date,
viewMode: DPGlobal.modes[this.viewMode].clsName
});
this.setValue(this._date.getTime());
this.notifyChange();
this.set();
} else if (val && val.trim()) {
if (this.date) this.set();
this.setValue(this._date.getTime());
if (this._date) this.set();
else input.val('');
} else {
if (this.date) {
if (this._date) {
this.setValue(null);
// unset the date when the input is
// erased
this.$element.trigger({
type: 'changeDate',
date: null,
viewMode: DPGlobal.modes[this.viewMode].clsName
});
this.notifyChange();
}

@@ -737,3 +746,3 @@ }

if (rv === 0) rv = 12;
else rv = rv % 12;
else if (rv !== 12) rv = rv % 12;
} else if (property === 'Period12') {

@@ -800,3 +809,3 @@ if (d.getUTCHours() >= 12) return 'PM';

if (/pm/i.test(parsed.Period12)) {
hours = (hours + 12) % 24;
if (hours != 12) hours = (hours + 12) % 24;
} else {

@@ -995,3 +1004,3 @@ hours = hours % 12;

ms: {property: 'UTCMilliseconds', getPattern: function() {return '([0-9]{1,3})\\b';}},
HH: {property: 'Hours12', getPattern: function() {return '(0?[0-9]|1[0-2])\\b';}},
HH: {property: 'Hours12', getPattern: function() {return '(0?[1-9]|1[0-2])\\b';}},
PP: {property: 'Period12', getPattern: function() {return '(AM|PM|am|pm|Am|aM|Pm|pM)\\b';}}

@@ -1015,3 +1024,4 @@ };

function padLeft(s, l, c) {
return Array(l - s.length + 1).join(c || ' ') + s;
if (l < s.length) return s;
else return Array(l - s.length + 1).join(c || ' ') + s;
}

@@ -1018,0 +1028,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