Skip to content

Commit

Permalink
Fixed bugs with timezone support
Browse files Browse the repository at this point in the history
- fixed toGMTString() method to output the correct value
  • Loading branch information
valkirilov committed Jun 25, 2020
1 parent 8169695 commit 1d4606d
Show file tree
Hide file tree
Showing 15 changed files with 1,653 additions and 1,635 deletions.
248 changes: 114 additions & 134 deletions dist/mtr-datepicker.min.js

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions docs/MtrDatepicker.html
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ <h4 class="name" id="~xDown"><span class="type-signature">(inner) </span>xDown<s

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1806">line 1806</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1807">line 1807</a>
</li></ul></dd>


Expand Down Expand Up @@ -452,7 +452,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1627">line 1627</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1628">line 1628</a>
</li></ul></dd>


Expand Down Expand Up @@ -589,7 +589,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1595">line 1595</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1596">line 1596</a>
</li></ul></dd>


Expand Down Expand Up @@ -745,7 +745,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line903">line 903</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line904">line 904</a>
</li></ul></dd>


Expand Down Expand Up @@ -853,7 +853,7 @@ <h4 class="name" id="~createMarkup"><span class="type-signature">(inner) </span>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line437">line 437</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line438">line 438</a>
</li></ul></dd>


Expand Down Expand Up @@ -990,7 +990,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line832">line 832</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line833">line 833</a>
</li></ul></dd>


Expand Down Expand Up @@ -1145,7 +1145,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1670">line 1670</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1671">line 1671</a>
</li></ul></dd>


Expand Down Expand Up @@ -1251,7 +1251,7 @@ <h4 class="name" id="~createRangeForDate"><span class="type-signature">(inner) <

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1686">line 1686</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1687">line 1687</a>
</li></ul></dd>


Expand Down Expand Up @@ -1392,7 +1392,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line530">line 530</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line531">line 531</a>
</li></ul></dd>


Expand Down Expand Up @@ -1547,7 +1547,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1933">line 1933</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1940">line 1940</a>
</li></ul></dd>


Expand Down Expand Up @@ -1709,7 +1709,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1818">line 1818</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1819">line 1819</a>
</li></ul></dd>


Expand Down Expand Up @@ -2004,7 +2004,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1661">line 1661</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1662">line 1662</a>
</li></ul></dd>


Expand Down Expand Up @@ -2182,7 +2182,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1644">line 1644</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1645">line 1645</a>
</li></ul></dd>


Expand Down Expand Up @@ -2319,7 +2319,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1789">line 1789</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1790">line 1790</a>
</li></ul></dd>


Expand Down Expand Up @@ -2611,7 +2611,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1514">line 1514</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1515">line 1515</a>
</li></ul></dd>


Expand Down Expand Up @@ -2703,7 +2703,7 @@ <h4 class="name" id="~smooth_scroll_to"><span class="type-signature">(inner) </s

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1716">line 1716</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1717">line 1717</a>
</li></ul></dd>


Expand Down Expand Up @@ -2865,7 +2865,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1031">line 1031</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1032">line 1032</a>
</li></ul></dd>


Expand Down Expand Up @@ -3025,7 +3025,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1483">line 1483</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1484">line 1484</a>
</li></ul></dd>


Expand Down Expand Up @@ -3211,7 +3211,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1071">line 1071</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line1072">line 1072</a>
</li></ul></dd>


Expand Down Expand Up @@ -3281,7 +3281,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="MtrDatepi
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Thu Jun 25 2020 11:09:50 GMT+0300 (Eastern European Summer Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Thu Jun 25 2020 15:18:16 GMT+0300 (Eastern European Summer Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
4 changes: 2 additions & 2 deletions docs/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ <h4 class="name" id="init"><span class="type-signature"></span>init<span class="

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line2038">line 2038</a>
<a href="mtr-datepicker.js.html">mtr-datepicker.js</a>, <a href="mtr-datepicker.js.html#line2045">line 2045</a>
</li></ul></dd>


Expand Down Expand Up @@ -244,7 +244,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="MtrDatepi
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Thu Jun 25 2020 11:09:50 GMT+0300 (Eastern European Summer Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Thu Jun 25 2020 15:18:16 GMT+0300 (Eastern European Summer Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="MtrDatepi
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Thu Jun 25 2020 11:09:50 GMT+0300 (Eastern European Summer Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Thu Jun 25 2020 15:18:16 GMT+0300 (Eastern European Summer Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/mtr-datepicker-timezones.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="MtrDatepi
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Thu Jun 25 2020 11:09:50 GMT+0300 (Eastern European Summer Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Thu Jun 25 2020 15:18:16 GMT+0300 (Eastern European Summer Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
33 changes: 20 additions & 13 deletions docs/mtr-datepicker.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ <h1 class="page-title">Source: mtr-datepicker.js</h1>
step: 1,
maxlength: 4
},
animations: true, // Responsible for the transition of the sliders - animated or static
smartHours: false, // Make auto swicth between AM/PM when moving from 11AM to 12PM or backwards
future: false, // Validate the date to be only in the future
disableAmPm: false, // Disable the 12 hours time format and go to a full 24 hours experience
animations: true, // Responsible for the transition of the sliders - animated or static
smartHours: false, // Make auto switch between AM/PM when moving from 11AM to 12PM or backwards
future: false, // Validate the date to be only in the future
disableAmPm: false, // Disable the 12 hours time format and go to a full 24 hours experience
validateAfter: true, // perform the future validation after the date change
utcTimezone: 0, // change the local timezone to a specific one
utcTimezone: 0, // change the local timezone to a specific one

transitionDelay: 100,
transitionValidationDelay: 500,
references: { // Used to store references to the main elements
references: { // Used to store references to the main elements
hours: null
},

Expand Down Expand Up @@ -200,7 +200,7 @@ <h1 class="page-title">Source: mtr-datepicker.js</h1>
config.smartHours = input.smartHours !== undefined ? input.smartHours : config.smartHours;
config.disableAmPm = input.disableAmPm !== undefined ? input.disableAmPm : config.disableAmPm;

// Change the defauls if the AM/PM is disabled
// Change the defaults if the AM/PM is disabled
if (config.disableAmPm) {
config.hours.min = 0;
config.hours.max = 23;
Expand All @@ -221,7 +221,8 @@ <h1 class="page-title">Source: mtr-datepicker.js</h1>
}

var localTimezoneOffsetTimestamp = values.date.getTime() + (values.date.getTimezoneOffset() * 60 * 1000);
var timezoneOffsetTimestamp = localTimezoneOffsetTimestamp + (config.utcTimezone.offset * 60 * 60 * 1000);
var timezoneOffsetTimestamp = localTimezoneOffsetTimestamp + (config.utcTimezone.offset * 60 * 60 * 1000);

values.date = new Date(timezoneOffsetTimestamp);
values.timestamp = values.date.getTime();

Expand Down Expand Up @@ -420,7 +421,7 @@ <h1 class="page-title">Source: mtr-datepicker.js</h1>
result = false;
}

// If there are any erros return a new target element with notice for the users
// If there are any errors return a new target element with notice for the users
if (!result) {
targetElement = byId(input.target);

Expand All @@ -430,7 +431,7 @@ <h1 class="page-title">Source: mtr-datepicker.js</h1>

var errorElement = document.createElement('div');
addClass(errorElement, 'mtr-error-message');
errorElement.appendChild(document.createTextNode('An error has occured during the initialization of the datepicker.'));
errorElement.appendChild(document.createTextNode('An error has occurred during the initialization of the datepicker.'));

targetElement.appendChild(errorElement);
}
Expand Down Expand Up @@ -1882,7 +1883,7 @@ <h1 class="page-title">Source: mtr-datepicker.js</h1>

// Here is a set of the default Date function
// We are providing them because the user are familiar with them and
// maybe this way they will implemet this library easily in their system
// maybe this way they will implement this library easily in their system

// "Wed Sep 23 2015"
var toDateString = function() {
Expand All @@ -1891,7 +1892,13 @@ <h1 class="page-title">Source: mtr-datepicker.js</h1>

// "Wed, 23 Sep 2015 08:43:47 GMT"
var toGMTString = function() {
return values.date.toGMTString();
// Remove the offsets of the timezone
var localTimezoneOffsetTimestamp = values.date.getTime() - (values.date.getTimezoneOffset() * 60 * 1000);
var timezoneOffsetTimestamp = localTimezoneOffsetTimestamp - (config.utcTimezone.offset * 60 * 60 * 1000);

var date = new Date(timezoneOffsetTimestamp);

return date.toGMTString();
};

// "2015-09-23T08:43:47.284Z"
Expand Down Expand Up @@ -2125,7 +2132,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="MtrDatepi
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Thu Jun 25 2020 11:09:50 GMT+0300 (Eastern European Summer Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Thu Jun 25 2020 15:18:16 GMT+0300 (Eastern European Summer Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<link rel="stylesheet" type="text/css" href="demo/cosmo.bootstrap.min.css">

<!-- Custom styles for this template -->
<link rel="stylesheet" type="text/css" href="dist/mtr-datepicker.min.css?rel=1593072588151" />
<link rel="stylesheet" type="text/css" href="dist/mtr-datepicker.default-theme.min.css?rel=1593072588151" />
<link rel="stylesheet" type="text/css" href="dist/mtr-datepicker.min.css?rel=1593087491789" />
<link rel="stylesheet" type="text/css" href="dist/mtr-datepicker.default-theme.min.css?rel=1593087491797" />
<link rel="stylesheet" type="text/css" href="demo/jumbotron-narrow.css" />

<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=yyxxeK88Mx">
Expand Down Expand Up @@ -162,7 +162,7 @@ <h1 id="demo" class="text-center">Demo</h1>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="libs/bootstrap/js/bootstrap.min.js"></script>

<script type="text/javascript" src="dist/mtr-datepicker.min.js?rel=1593072588152"></script>
<script type="text/javascript" src="dist/mtr-datepicker.min.js?rel=1593087491798"></script>

<script type="text/javascript">
var demoDatepicker = new MtrDatepicker({
Expand Down
16 changes: 8 additions & 8 deletions libs/anchorjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
"test": "npm run lint && npm run jasmine"
},
"devDependencies": {
"eslint": "~2.11.1",
"jasmine-core": "~2.4.1",
"karma": "~0.13.22",
"karma-cli": "~1.0.0",
"karma-jasmine": "~1.0.2",
"karma-phantomjs-launcher": "~1.0.0",
"phantomjs-prebuilt": "~2.1.7",
"uglify-js": "~2.6.2"
"eslint": "~7.3.1",
"jasmine-core": "~3.5.0",
"karma": "~5.1.0",
"karma-cli": "~2.0.0",
"karma-jasmine": "~3.3.1",
"karma-phantomjs-launcher": "~1.0.4",
"phantomjs-prebuilt": "~2.1.16",
"uglify-js": "~3.10.0"
}
}

0 comments on commit 1d4606d

Please sign in to comment.