gwtproject / gwt

GWT Open Source Project
http://www.gwtproject.org
1.49k stars 370 forks source link

DatePicker cannot be modified to have February with 29 days for all the years (Hijri Calendar) #7170

Closed dankurka closed 9 years ago

dankurka commented 9 years ago

Originally reported on Google Code with ID 7173

Found in GWT Release:

2.4.0

Encountered on OS / Browser (e.g. WinXP, IE8-9, FF7):

Any Browser

Detailed description (please be as specific as possible):

DatePicker cannot be customized to have February with 29 days (Hijri Calendar). Whenever
we try to set date as 29 Feb (Any year other than leap year) it is automatically getting
normalized to the next date in the calendar i.e., March 1 and above.

Shortest code snippet which demonstrates issue (please indicate where
actual result differs from expected result):

     DateBox dateBox = new DateBox();
     dateBox.setValue(new Date( 2013, 1, 29 )); // <-- Actual expected date is 29/02/2013
but is normalized to 01/03/2013 (dd/mm/yyyy)

Workaround if you have one:

Tried to extend the BaseCalendar.java of sun.util.calendar package, but it din't get
compiled.

Links to relevant GWT Developer Forum posts:
None

Reported by abhijith7 on 2012-02-06 07:35:42

dankurka commented 9 years ago
It's not a problem with DatePicker, but with java.util.Date and what's possible to do
in JavaScript.
Section 15.9.1.3 of ECMAScript 5 says: "ECMAScript uses an extrapolated Gregorian system".
Also, java.util.Date uses the Gregorian calendar too: http://docs.oracle.com/javase/6/docs/api/java/util/Date.html
(and note that turning 2013-02-29 into 2013-03-01 is the expected behavior)

If you want to use another calendar, you'd need to use the java.util.Calendar API which
is not emulated in GWT; or the JodaTime project: http://joda-time.sourceforge.net/apidocs/org/joda/time/chrono/IslamicChronology.html
(I suppose it's the same as the Hijri calendar).
There's a new API in the works for a future version of Java that should be easier to
emulate in GWT, and which will support the Hijrah calendar (which I suppose is another
transliteration for Hijri): http://threeten.sourceforge.net/apidocs/javax/time/i18n/HijrahChronology.html

Reported by t.broyer on 2012-02-06 09:16:59

dankurka commented 9 years ago
I should also point out that, just as with Issue 611, this is not an issue that the
GWT team plans to address, but we are willing to look at (light weight) patches.

Reported by clayberg@google.com on 2012-02-06 13:32:34