Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#7014 closed defect (fixed)

test case dojo/tests/date/stamp.js is failing in timezone +05:30

Reported by: guest Owned by: Adam Peller
Priority: high Milestone: 1.2
Component: Date Version: 1.1.1
Keywords: Cc:
Blocked By: Blocking:

Description

I am executing the DOJO test suite as part of HtmlUnit? test cases. And it is failing because of stamp.js. First I posted this to htmlUnit list but found that it is Dojo issue and HtmlUnit? developer confirmed that it is reproducible for timezone +05:30 and is dojo issue.

com.gargoylesoftware.htmlunit.libraries.Dojo102Test is failing with following trace

org.junit.ComparisonFailure?: expected:<[PASSED test: test_date_iso]> but was:<[_AssertFailure: doh._AssertFailure: assertEqual() failed: expected |5| but got |35|: assertEqual() failed: expected |5| but got |35|]>

Found the source of the problem but could not understand it. In fact the behavior is puzzling as test case is perfectly right. And my knowledge of JavaScript? is limited so could not verify the implementation of dojo.date.stamp.fromISOString()

Can any one help me understand why is this failing on my machine?

var rfc = "2005-06-29T08:05:00-07:00"; var date = dojo.date.stamp.fromISOString(rfc);

.....

t.is(15,date.getUTCHours()); t.is(5,date.getMinutes());

Test case is passing if I change the code to

Changed timezone

var rfc = "2005-06-29T08:05:00-07:30"; var date = dojo.date.stamp.fromISOString(rfc);

.....

t.is(15,date.getUTCHours()); t.is(5,date.getMinutes());

OR to

Removed timezone

var rfc = "2005-06-29T08:05:00"; var date = dojo.date.stamp.fromISOString(rfc);

.....

t.is(2,date.getUTCHours()); t.is(5,date.getMinutes());

Here I changed the UTC Hours to 2 as my time zone is +05:30.

Change History (5)

comment:1 Changed 11 years ago by Adam Peller

Yeah, the test case is invalid. I gather if you change the '5' to '35' it will pass. How about changing getMinutes to getUTCMinutes?

How do I set +05:30 as my timezone? I'm guessing this is India. When I set it on my Mac, I get GMT-05:00 (IST) on FF/Mac.

comment:2 Changed 11 years ago by guest

What does dojo.date.stamp.fromISOString(rfc) do?

I had assumed that it creates Date object from the given string for the timezone specified in the string. And in that case test case is correct and problem is with the implementation.

In case my assumption is wrong and fromISOString(rfc) converts the specified time to local timezone then the test case is incorrect. And in this case we need to modify test case. Changing getMinutes() to getUTCMinutes() fixes the issue.

As for setting the timezone, I don't know about Mac, I just change the timezone from the drop down in "Date and Time Properties" dialog in windows. There should be something similar on Mac.

comment:3 Changed 11 years ago by Adam Peller

So you can't create a Date object for a particular timezone; normally in JS you create a Date object with the constructor in your local time zone, or you can create it using UTC getter/setter references (or using a posix seconds since epoch)

comment:4 Changed 11 years ago by Adam Peller

Milestone: 1.2
Resolution: fixed
Status: newclosed

fixed in [14154]

comment:5 Changed 11 years ago by Adam Peller

oops. fixed in [14157]

Note: See TracTickets for help on using tickets.