ant icon indicating copy to clipboard operation
ant copied to clipboard

Add tests for parseLenientDateTime

Open GKFX opened this issue 8 years ago • 4 comments

As requested for #36.

GKFX avatar Sep 29 '17 14:09 GKFX

Many thanks.

I've fixed the line-ends to contain line-feeds only as I couldn't merge your patch on a Linux box, therefore the PR now has conflicts. Sorry about that.

As written the tests depend on the timezone of the machine running the tests:

Testcase: testLenientDateTime took 0,006 sec
	FAILED
expected:<1488622440000> but was:<1488618840000>
junit.framework.AssertionFailedError: expected:<1488622440000> but was:<1488618840000>
	at org.junit.Assert.fail(Assert.java:88)
	at org.junit.Assert.failNotEquals(Assert.java:743)
	at org.junit.Assert.assertEquals(Assert.java:118)
	at org.junit.Assert.assertEquals(Assert.java:555)
	at org.junit.Assert.assertEquals(Assert.java:542)
	at org.apache.tools.ant.util.DateUtilsTest.testLenientDateTime(DateUtilsTest.java:119)

this is on GMT+2 and off by an hour. But as this is off by an hour I think it is more about me being in daylight saving time right now while the date you picked was not (most countries of the EU switch on the last weekends of March and October).

bodewig avatar Sep 30 '17 04:09 bodewig

That's interesting; since the values I were testing were coming out GMT, and I'm in British Summer Time at the moment, I thought the timezone was being set to UTC and so it would work everywhere. Apparently not, so I'll make a note in the documentation.

GKFX avatar Oct 02 '17 08:10 GKFX

I haven't found the time to dig deeply into the issue, but it would be good to understand where exactly things turn into unexpected directions.

bodewig avatar Oct 02 '17 08:10 bodewig

Changing the date to within BST does mean that, for me, it gets interpreted as being a BST date. So, given what you see as well, I think that format parses date/times as if they were what you had seen on a local clock. I don't see anything in SimpleDateFormat's Javadoc that confirms that though.

On 2 October 2017 at 09:46, Stefan Bodewig [email protected] wrote:

I haven't found the time to dig deeply into the issue, but it would be good to understand where exactly things turn into unexpected directions.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/apache/ant/pull/40#issuecomment-333475300, or mute the thread https://github.com/notifications/unsubscribe-auth/AFHASjBNDG_dInS6rwUFws3xXBTksCElks5soKL-gaJpZM4Poy-o .

GKFX avatar Oct 02 '17 08:10 GKFX