Skip to content

Commit

Permalink
fix: DatePicker month off by 1 in Android (#4872)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Vakrilov committed Sep 26, 2017
1 parent 6d7c1ff commit 1e47117
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions tests/app/ui/date-picker/date-picker-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ export class DatePickerTest extends testModule.UITest<datePickerModule.DatePicke
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() {
const expectedValue = 1980;
this.testView.year = expectedValue;
Expand Down
2 changes: 1 addition & 1 deletion tns-core-modules/ui/date-picker/date-picker.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class DatePicker extends DatePickerBase {
picker.setCalendarViewShown(false);
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;
return picker;
}
Expand Down

0 comments on commit 1e47117

Please sign in to comment.