Skip to content
This repository has been archived by the owner on Feb 14, 2019. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into bug/prevent-bad-c…
Browse files Browse the repository at this point in the history
…haracters

* upstream/master:
  Version bump
  Version bump
  Fixed onRender method according to PR #571
  Version bump
  Fix exception thrown after clearing value using built in clear button
  Ensure we are supporting all browsers for timezone abbreviation * browsers on a different OS will return a different format
  Update bootstrap-datetimepicker.css
  • Loading branch information
davidpatters0n committed Dec 9, 2016
2 parents 66ee0f1 + 0175948 commit 10cc56b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ This event is fired when a day is rendered inside the datepicker. Should return
$('#date-end')
.datetimepicker({
onRender: function(date) {
return ev.date.valueOf() < date-start-display.valueOf() ? ' disabled' : '';
return date.valueOf() < date-start-display.valueOf() ? ' disabled' : '';
}
});
```
Expand Down
6 changes: 3 additions & 3 deletions css/bootstrap-datetimepicker.css
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fdd49a), to(#fdf59a));
background-image: -webkit-linear-gradient(top, #fdd49a, #fdf59a);
background-image: -o-linear-gradient(top, #fdd49a, #fdf59a);
background-image: linear-gradient(top, #fdd49a, #fdf59a);
background-image: linear-gradient(to bottom, #fdd49a, #fdf59a);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fdd49a', endColorstr='#fdf59a', GradientType=0);
border-color: #fdf59a #fdf59a #fbed50;
Expand Down Expand Up @@ -244,7 +244,7 @@
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
background-image: -o-linear-gradient(top, #0088cc, #0044cc);
background-image: linear-gradient(top, #0088cc, #0044cc);
background-image: linear-gradient(to bottom, #0088cc, #0044cc);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0);
border-color: #0044cc #0044cc #002a80;
Expand Down Expand Up @@ -343,7 +343,7 @@
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
background-image: -o-linear-gradient(top, #0088cc, #0044cc);
background-image: linear-gradient(top, #0088cc, #0044cc);
background-image: linear-gradient(to bottom, #0088cc, #0044cc);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0);
border-color: #0044cc #0044cc #002a80;
Expand Down
2 changes: 1 addition & 1 deletion css/bootstrap-datetimepicker.min.css

Large diffs are not rendered by default.

28 changes: 24 additions & 4 deletions js/bootstrap-datetimepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@
return isFixed;
}

// Add timezone abbreviation support for ie6+, Chrome, Firefox
function timeZoneAbbreviation() {
var abbreviation, date, formattedStr, i, len, matchedStrings, ref, str;
date = (new Date).toString();
formattedStr = ((ref = date.split('(')[1]) != null ? ref.slice(0, -1) : void 0) || date.split(' ');
if (formattedStr instanceof Array) {
matchedStrings = [];
for (i = 0, len = formattedStr.length; i < len; i++) {
str = formattedStr[i];
if (abbreviation = (ref = str.match(/\b[A-Z]+\b/)) != null ? ref[0] : void 0) {
matchedStrings.push(abbreviation);
}
}
formattedStr = matchedStrings.pop();
}
return formattedStr;
};

function UTCDate() {
return new Date(Date.UTC.apply(Date, arguments));
}
Expand Down Expand Up @@ -109,8 +127,7 @@
this.initialDate = options.initialDate || new Date();
this.zIndex = options.zIndex || this.element.data('z-index') || undefined;
this.title = typeof options.title === 'undefined' ? false : options.title;
this.defaultTimeZone = (new Date).toString().split('(')[1].slice(0, -1);
this.timezone = options.timezone || this.defaultTimeZone;
this.timezone = options.timezone || timeZoneAbbreviation();

this.icons = {
leftArrow: this.fontAwesome ? 'fa-arrow-left' : (this.bootcssVer === 3 ? 'glyphicon-arrow-left' : 'icon-arrow-left'),
Expand Down Expand Up @@ -253,6 +270,7 @@

this.weekStart = ((options.weekStart || this.element.data('date-weekstart') || dates[this.language].weekStart || 0) % 7);
this.weekEnd = ((this.weekStart + 6) % 7);
this.onRender = options.onRender || function () { return ''; };
this.startDate = -Infinity;
this.endDate = Infinity;
this.datesDisabled = [];
Expand Down Expand Up @@ -388,6 +406,9 @@

getDate: function () {
var d = this.getUTCDate();
if (d === null) {
return null;
}
return new Date(d.getTime() + (d.getTimezoneOffset() * 60000));
},

Expand Down Expand Up @@ -677,12 +698,11 @@
nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
nextMonth = nextMonth.valueOf();
var html = [];
var clsName;
var clsName = this.onRender(prevMonth)
while (prevMonth.valueOf() < nextMonth) {
if (prevMonth.getUTCDay() == this.weekStart) {
html.push('<tr>');
}
clsName = '';
if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
clsName += ' old';
} else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
Expand Down
2 changes: 1 addition & 1 deletion js/bootstrap-datetimepicker.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "bootstrap-datetime-picker",
"homepage": "http://www.malot.fr/bootstrap-datetimepicker/",
"description": "Both Date and Time picker widget based on twitter bootstrap",
"version": "2.3.11",
"version": "2.3.14",
"license": "Apache 2.0",
"author": {
"name": "Sebastien Malot"
Expand Down

0 comments on commit 10cc56b

Please sign in to comment.