Opened 9 years ago
Last modified 6 years ago
#17315 assigned defect
stamp.fromISOString returns a time that is 10 minutes earlier than the supplied string
Reported by: | aedgar93 | Owned by: | dylan |
---|---|---|---|
Priority: | undecided | Milestone: | 1.15 |
Component: | Date | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
I will supply a string to the function and the resulting date will be 10 minutes earlier. For example, I will submit ISO formatted string with the time of 10:30 and the resulting time will be at 10:20
Attachments (2)
Change History (14)
comment:1 Changed 9 years ago by
Component: | General → Date |
---|---|
Owner: | set to aedgar93 |
Status: | new → pending |
comment:2 Changed 9 years ago by
Status: | pending → new |
---|
I have a function that looks like this:
function(isoDateString, format) { console.log(isoDateString); var isoDateObject = stamp.fromISOString(isoDateString); console.log(isoDateObject); }
The console then outputs: 2013-07-15T13:40:05-0600 Mon Jul 15 2013 13:30:05 GMT-0600 (Mountain Daylight Time)
As you can see the input time is 13:40 and the output is 13:30.
Thank you
comment:3 Changed 9 years ago by
Status: | new → pending |
---|
OK, but you can follow my instructions and an actual test case rather than a code snippet?
Please attach a test case using the "attach file" button. It should be a single HTML file that we can load in the browser (i.e. not PHP, JSP, etc.).
comment:4 Changed 9 years ago by
I didn't submit a test case either, but wrote a more complete c/p'able version from the alleged input/output:
(function(){ require(["dojo/date/stamp"], function(stamp){ var isoDateObject = stamp.fromISOString("2013-07-15T13:40:05-0600"); console.log(isoDateObject); // Mon Jul 15 2013 13:30:05 GMT-0400 (EDT) }) })();
I could attach an .html w/ an additional dojo.js included, but writing a proper test case would be fun because it is time/date based. and by fun I really mean pain.
comment:5 Changed 9 years ago by
Owner: | aedgar93 deleted |
---|---|
Status: | pending → new |
OK, that reproduces for me, seems to be a bug.
comment:6 Changed 9 years ago by
Thought about how to unit test this without caring about localization. isoDateObject.getMinutes() (and UTCMinutes) both return 30
from the above string.
comment:7 Changed 8 years ago by
I ran across the same problem. There is an error in the regular expression that parses the date format
/(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(.\d+)?)?((?:[+-](\d{2}):(\d{2}))|Z)?)?$/;
The decimal point in the seconds fraction selection should be escaped so that it only selects decimal points instead of any character. The colon in the time zone selection should be optional so it can select -0400 instead of just -04:00.
This fixed the problem for me
/(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(\.\d+)?)?((?:[+-](\d{2}):?(\d{2}))|Z)?)?$/;
comment:11 Changed 7 years ago by
Milestone: | tbd → 1.12 |
---|---|
Owner: | set to dylan |
Status: | new → assigned |
comment:12 Changed 6 years ago by
Milestone: | 1.13 → 1.15 |
---|
Ticket planning... move current 1.13 tickets out to 1.15 to make it easier to move tickets into the 1.13 milestone.
That's odd, but all our tests are working. See https://github.com/dojo/dojo/blob/master/tests/date/stamp.js. Can you attach a test case that fails?