fix: DatePicker month off by 1 in Android (#4872)

This commit is contained in:
Alexander Vakrilov
2017-09-26 09:44:33 +03:00
committed by GitHub
parent 6d7c1ff295
commit 1e47117179
2 changed files with 19 additions and 1 deletions

View File

@ -99,6 +99,24 @@ export class DatePickerTest extends testModule.UITest<datePickerModule.DatePicke
TKUnit.assertEqual(actualValue, expectedValue); TKUnit.assertEqual(actualValue, expectedValue);
} }
public test_WhenCreated_NativeYearIsCurrentYear() {
const actualValue = datePickerTestsNative.getNativeYear(this.testView);
const expectedValue = currentDate.getFullYear();
TKUnit.assertEqual(actualValue, expectedValue);
}
public test_WhenCreated_NativeMonthIsCurrentMonth() {
const actualValue = datePickerTestsNative.getNativeMonth(this.testView);
const expectedValue = currentDate.getMonth() + 1;
TKUnit.assertEqual(actualValue, expectedValue);
}
public test_WhenCreated_NativeDayIsCurrentDay() {
const actualValue = datePickerTestsNative.getNativeDay(this.testView);;
const expectedValue = currentDate.getDate();
TKUnit.assertEqual(actualValue, expectedValue);
}
public testYearFromLocalToNative() { public testYearFromLocalToNative() {
const expectedValue = 1980; const expectedValue = 1980;
this.testView.year = expectedValue; this.testView.year = expectedValue;

View File

@ -59,7 +59,7 @@ export class DatePicker extends DatePickerBase {
picker.setCalendarViewShown(false); picker.setCalendarViewShown(false);
const listener = new DateChangedListener(this); const listener = new DateChangedListener(this);
picker.init(this.year, this.month, this.day, listener); picker.init(this.year, this.month - 1, this.day, listener);
(<any>picker).listener = listener; (<any>picker).listener = listener;
return picker; return picker;
} }