Skip to content

Commit

Permalink
Varying timezone fix
Browse files Browse the repository at this point in the history
  • Loading branch information
androidi committed Dec 27, 2017
1 parent 3f87a1a commit 8ea14e0
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 38 deletions.
14 changes: 5 additions & 9 deletions dist/calenstyle-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3866,28 +3866,24 @@ CalenStyle.prototype = {
return iUnitDiff;
},

// Offset from UTC in minutes
_iUTCoffset: new Date().getTimezoneOffset() * $.CalenStyle.extra.iMS.m,

// Public Method
compareDates: function(dDate1, dDate2)
{
var to = this;

// Get timestamps as integers
var tsD1 = dDate1.getTime() - to._iUTCoffset;
var tsD2 = dDate2.getTime() - to._iUTCoffset;
var iTzOffset = dDate1.getTimezoneOffset() * 60000;
var tsD1 = dDate1.getTime() - iTzOffset;
var tsD2 = dDate2.getTime() - iTzOffset;

// Calculate offsets from 00:00:00 hh:mm:ss
var iOffD1 = tsD1 % $.CalenStyle.extra.iMS.d;
var iOffD2 = tsD2 % $.CalenStyle.extra.iMS.d;

// Calculate date difference
var iDiff = (tsD1 - iOffD1 - (tsD2 - iOffD2));
var iDateDiff = Math.floor(iDiff / $.CalenStyle.extra.iMS.d);

return (iDateDiff === 0) ? iDateDiff: (iDateDiff/Math.abs(iDateDiff));
},
return Math.sign(iDiff / $.CalenStyle.extra.iMS.d);
},

// Public Method
compareDateTimes: function(dDate1, dDate2)
Expand Down
14 changes: 5 additions & 9 deletions dist/calenstyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3870,28 +3870,24 @@ CalenStyle.prototype = {
return iUnitDiff;
},

// Offset from UTC in minutes
_iUTCoffset: new Date().getTimezoneOffset() * $.CalenStyle.extra.iMS.m,

// Public Method
compareDates: function(dDate1, dDate2)
{
var to = this;

// Get timestamps as integers
var tsD1 = dDate1.getTime() - to._iUTCoffset;
var tsD2 = dDate2.getTime() - to._iUTCoffset;
var iTzOffset = dDate1.getTimezoneOffset() * 60000;
var tsD1 = dDate1.getTime() - iTzOffset;
var tsD2 = dDate2.getTime() - iTzOffset;

// Calculate offsets from 00:00:00 hh:mm:ss
var iOffD1 = tsD1 % $.CalenStyle.extra.iMS.d;
var iOffD2 = tsD2 % $.CalenStyle.extra.iMS.d;

// Calculate date difference
var iDiff = (tsD1 - iOffD1 - (tsD2 - iOffD2));
var iDateDiff = Math.floor(iDiff / $.CalenStyle.extra.iMS.d);

return (iDateDiff === 0) ? iDateDiff: (iDateDiff/Math.abs(iDateDiff));
},
return Math.sign(iDiff / $.CalenStyle.extra.iMS.d);
},

// Public Method
compareDateTimes: function(dDate1, dDate2)
Expand Down
2 changes: 1 addition & 1 deletion dist/calenstyle.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/calenstyle.min.js

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions src/calenstyle-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3866,28 +3866,24 @@ CalenStyle.prototype = {
return iUnitDiff;
},

// Offset from UTC in minutes
_iUTCoffset: new Date().getTimezoneOffset() * $.CalenStyle.extra.iMS.m,

// Public Method
compareDates: function(dDate1, dDate2)
{
var to = this;

// Get timestamps as integers
var tsD1 = dDate1.getTime() - to._iUTCoffset;
var tsD2 = dDate2.getTime() - to._iUTCoffset;
var iTzOffset = dDate1.getTimezoneOffset() * 60000;
var tsD1 = dDate1.getTime() - iTzOffset;
var tsD2 = dDate2.getTime() - iTzOffset;

// Calculate offsets from 00:00:00 hh:mm:ss
var iOffD1 = tsD1 % $.CalenStyle.extra.iMS.d;
var iOffD2 = tsD2 % $.CalenStyle.extra.iMS.d;

// Calculate date difference
var iDiff = (tsD1 - iOffD1 - (tsD2 - iOffD2));
var iDateDiff = Math.floor(iDiff / $.CalenStyle.extra.iMS.d);

return (iDateDiff === 0) ? iDateDiff: (iDateDiff/Math.abs(iDateDiff));
},
return Math.sign(iDiff / $.CalenStyle.extra.iMS.d);
},

// Public Method
compareDateTimes: function(dDate1, dDate2)
Expand Down
14 changes: 5 additions & 9 deletions src/calenstyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3870,28 +3870,24 @@ CalenStyle.prototype = {
return iUnitDiff;
},

// Offset from UTC in minutes
_iUTCoffset: new Date().getTimezoneOffset() * $.CalenStyle.extra.iMS.m,

// Public Method
compareDates: function(dDate1, dDate2)
{
var to = this;

// Get timestamps as integers
var tsD1 = dDate1.getTime() - to._iUTCoffset;
var tsD2 = dDate2.getTime() - to._iUTCoffset;
var iTzOffset = dDate1.getTimezoneOffset() * 60000;
var tsD1 = dDate1.getTime() - iTzOffset;
var tsD2 = dDate2.getTime() - iTzOffset;

// Calculate offsets from 00:00:00 hh:mm:ss
var iOffD1 = tsD1 % $.CalenStyle.extra.iMS.d;
var iOffD2 = tsD2 % $.CalenStyle.extra.iMS.d;

// Calculate date difference
var iDiff = (tsD1 - iOffD1 - (tsD2 - iOffD2));
var iDateDiff = Math.floor(iDiff / $.CalenStyle.extra.iMS.d);

return (iDateDiff === 0) ? iDateDiff: (iDateDiff/Math.abs(iDateDiff));
},
return Math.sign(iDiff / $.CalenStyle.extra.iMS.d);
},

// Public Method
compareDateTimes: function(dDate1, dDate2)
Expand Down

0 comments on commit 8ea14e0

Please sign in to comment.