X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Foutput%2FDateSelector.java;h=2557282abe8dad4b8737b9ff6fd6baa0e972d6d4;hb=6f621133a5fb40c0590d4ac1b80f6ad2bdd77f80;hp=22a0f620854eafb45a2f1826f62b4a8a572f1d2e;hpb=c0d62ad52b65d78806431b34ed2ae24bf58c1ada;p=gigi.git diff --git a/src/org/cacert/gigi/output/DateSelector.java b/src/org/cacert/gigi/output/DateSelector.java index 22a0f620..2557282a 100644 --- a/src/org/cacert/gigi/output/DateSelector.java +++ b/src/org/cacert/gigi/output/DateSelector.java @@ -4,7 +4,6 @@ import java.io.PrintWriter; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Calendar; -import java.util.GregorianCalendar; import java.util.Map; import java.util.TimeZone; @@ -13,6 +12,7 @@ import javax.servlet.http.HttpServletRequest; import org.cacert.gigi.GigiApiException; import org.cacert.gigi.localisation.Language; import org.cacert.gigi.output.template.Outputable; +import org.cacert.gigi.util.CalendarUtil; import org.cacert.gigi.util.DayDate; import org.cacert.gigi.util.HTMLEncoder; @@ -22,7 +22,7 @@ public class DateSelector implements Outputable { public DateSelector(String day, String month, String year, DayDate date) { this(day, month, year); - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTF")); + Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cal.setTimeInMillis(date.getTime()); this.day = cal.get(Calendar.DAY_OF_MONTH); this.month = cal.get(Calendar.MONTH) + 1; @@ -90,7 +90,7 @@ public class DateSelector implements Outputable { if (year != 0) { out.print(year); } - out.print("\" size=\"4\" autocomplete=\"off\">"); + out.println("\" size=\"4\" autocomplete=\"off\">"); } public void update(HttpServletRequest r) throws GigiApiException { @@ -115,10 +115,15 @@ public class DateSelector implements Outputable { } public boolean isValid() { - if ( !(1900 < year && 1 <= month && month <= 12 && 1 <= day && day <= 32)) { + if ( !(1890 < year && 1 <= month && month <= 12 && 1 <= day && day <= 32)) { return false; } - return true; // TODO checkdate + + if ( !CalendarUtil.isDateValid(year, month, day)) { + return false; + } + + return true; } @Override @@ -127,10 +132,7 @@ public class DateSelector implements Outputable { } public DayDate getDate() { - Calendar gc = GregorianCalendar.getInstance(); - gc.set(year, month - 1, day, 0, 0, 0); - gc.set(Calendar.MILLISECOND, 0); - return new DayDate(gc.getTime().getTime()); + return CalendarUtil.getDateFromComponents(year, month, day); } public static SimpleDateFormat getDateFormat() {