captbaritone / captbaritone/datejs

Adding time fails during DST switches

Open
#119 0 comments 0 reactions 0 assignees View on GitHub
auto-migrated Priority-Medium Type-Defect
Dominant language
JavaScript
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

```
What steps will reproduce the problem?

var d = new Date('Sun Mar 27 2011 01:59:00 GMT+0100 (CET)');
d.addMinutes(1);

What is the expected output? What do you see instead?

The expected result is 'Sun Mar 27 2011 03:00:00 GMT+0200 (CET)' but the actual
result is 'Sun Mar 27 2011 01:00:00 GMT+0200 (CET)'

The problem is that setMilliseconds() (which is the final operation on any time
adding/substraction in datejs) does not work across DST boundaries. The
solution is simple though:

--- a/horde/js/date/date.js
+++ b/horde/js/date/date.js
@@ -222,7 +222,7 @@
* @return {Date} this
*/
$P.addMilliseconds = function (value) {
- this.setMilliseconds(this.getMilliseconds() + value * 1);
+ this.setTime(this.getTime() + value * 1);
return this;
};

```

Original issue reported on code.google.com by `jan.schn...@gmail.com` on 27 Mar 2011 at 1:53

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.