Opened 6 years ago

Last modified 2 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)

isotest.diff (985 bytes) - added by dante 6 years ago.
added failing unit test
patch-17315.diff (687 bytes) - added by scribles 4 years ago.
Regular expression patch #17315

Download all attachments as: .zip

Change History (14)

comment:1 Changed 6 years ago by bill

Component: GeneralDate
Owner: set to aedgar93
Status: newpending

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?

comment:2 Changed 6 years ago by aedgar93

Status: pendingnew

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 6 years ago by bill

Status: newpending

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 6 years ago by dante

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.

Last edited 6 years ago by dante (previous) (diff)

comment:5 Changed 6 years ago by bill

Owner: aedgar93 deleted
Status: pendingnew

OK, that reproduces for me, seems to be a bug.

comment:6 Changed 6 years ago by dante

Thought about how to unit test this without caring about localization. isoDateObject.getMinutes() (and UTCMinutes) both return 30 from the above string.

Changed 6 years ago by dante

Attachment: isotest.diff added

added failing unit test

comment:7 Changed 4 years ago by scribles

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)?)?$/;

Changed 4 years ago by scribles

Attachment: patch-17315.diff added

Regular expression patch #17315

comment:8 Changed 4 years ago by scribles

I think this is the same issue as #17522

comment:9 Changed 4 years ago by bill

#17522 is a duplicate of this ticket.

comment:10 Changed 4 years ago by bill

#17522 has a patch and test case (albeit against DOH not Intern).

comment:11 Changed 3 years ago by dylan

Milestone: tbd1.12
Owner: set to dylan
Status: newassigned

comment:12 Changed 2 years ago by dylan

Milestone: 1.131.15

Ticket planning... move current 1.13 tickets out to 1.15 to make it easier to move tickets into the 1.13 milestone.

Note: See TracTickets for help on using tickets.