PDA

View Full Version : [CLOSED] Bug in com.extjs.gxt.ui.client.util.DateWrapper



raidan2
18 Jan 2011, 2:56 AM
Well, dudes, 12AM is not the actual start of the date (at least not in the USA or GB ).




public DateWrapper resetTime() {
Date date = asDate();
// remove millis
long msec = date.getTime();
msec = (msec / 1000) * 1000;
date.setTime(msec);

// reset time to 12am
date.setHours(12);
date.setMinutes(0);
date.setSeconds(0);
return new DateWrapper(date);
}Must be date.setHours(0);

sven
18 Jan 2011, 10:59 AM
This is not a bug, The method is exactly doing what it should do. You are probably looking for clearTime() or an own method that serves your needs

raidan2
18 Jan 2011, 2:10 PM
OK. Let's do it the hard way.

That method called from com.extjs.gxt.ui.client.widget.DatePicker


public void setValue(Date date, boolean supressEvent) {
this.value = new DateWrapper(date).resetTime();
if (rendered) {
update(value);
}
if (!supressEvent) {
DatePickerEvent de = new DatePickerEvent(this);
de.setDate(date);
fireEvent(Events.Select, de);
}
}


And that method setValue called every time user clicked on 'day' in DatePicker.
After changing day I got "19.01.2011 12:00:00". But it must be "19.01.2011 00:00:00"!

raidan2
18 Jan 2011, 2:12 PM
At least there must be the way to change that behaviour.
We expects that new day (just day without time) starts from midnight.

Method setValue firing event with correct date (without 12am starting). But com.extjs.gxt.ui.client.widget.form.DateField ignores that date in event. This class using getValue from DatePicker holding 12am date.

P.S. Maybe I'm wrong with that expectation. Just another overwritten GXT class to our code :(

kjordan2001
2 Aug 2011, 2:27 PM
I think the docs should at least be changed. 12:00:00 (what it's reset to) is not 12 am. It's 12 pm (i.e. noon). 12 am is the start of the day (i.e. midnight).

sven
2 Aug 2011, 11:38 PM
I think the docs should at least be changed. 12:00:00 (what it's reset to) is not 12 am. It's 12 pm (i.e. noon). 12 am is the start of the day (i.e. midnight).

This is fixed in SVN now