Skip to content

Commit

Permalink
Inconsistent behavior between datetime and date fields when used with…
Browse files Browse the repository at this point in the history
… year and month-year appearances (getodk#357)
  • Loading branch information
grzesiek2010 authored and lognaturel committed Jan 25, 2017
1 parent 22121a7 commit 8b96c4b
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,14 @@ private void hideDayFieldIfNotInFormat(FormEntryPrompt prompt) {
this.mDatePicker.setCalendarViewShown(false);
this.mDatePicker.setSpinnersShown(true);
}
mTimePicker.setVisibility(GONE);
} else if ("year".equals(appearance)) {
hideMonth = true;
if (Build.VERSION.SDK_INT >= 11) {
this.mDatePicker.setCalendarViewShown(false);
this.mDatePicker.setSpinnersShown(true);
}
mTimePicker.setVisibility(GONE);
} else if ("no-calendar".equals(appearance)) {
if (Build.VERSION.SDK_INT >= 11) {
this.mDatePicker.setCalendarViewShown(false);
Expand Down Expand Up @@ -286,9 +288,11 @@ public IAnswerData getAnswer() {
}
clearFocus();
DateTime ldt =
new DateTime(mDatePicker.getYear(), mDatePicker.getMonth() + 1,
mDatePicker.getDayOfMonth(), mTimePicker.getCurrentHour(),
mTimePicker.getCurrentMinute(), 0);
new DateTime(mDatePicker.getYear(),
(!showCalendar && hideMonth) ? 1 : mDatePicker.getMonth() + 1,
(!showCalendar && (hideMonth || hideDay)) ? 1 : mDatePicker.getDayOfMonth(),
(!showCalendar && (hideMonth || hideDay)) ? 0 : mTimePicker.getCurrentHour(),
(!showCalendar && (hideMonth || hideDay)) ? 0 : mTimePicker.getCurrentMinute(), 0);
//DateTime utc = ldt.withZone(DateTimeZone.forID("UTC"));
return new DateTimeData(ldt.toDate());
}
Expand Down

0 comments on commit 8b96c4b

Please sign in to comment.