FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: DatePicker month off by 1 in Android (#4872) · NativeScript/NativeScript@1e47117 · GitHub

Commit 1e47117

Browse files
Alexander Vakrilov
authored
fix: DatePicker month off by 1 in Android (#4872)
1 parent 6d7c1ff commit 1e47117

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎tests/app/ui/date-picker/date-picker-tests.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,24 @@ export class DatePickerTest extends testModule.UITest<datePickerModule.DatePicke
9999
TKUnit.assertEqual(actualValue, expectedValue);
100100
}
101101

102+
public test_WhenCreated_NativeYearIsCurrentYear() {
103+
const actualValue = datePickerTestsNative.getNativeYear(this.testView);
104+
const expectedValue = currentDate.getFullYear();
105+
TKUnit.assertEqual(actualValue, expectedValue);
106+
}
107+
108+
public test_WhenCreated_NativeMonthIsCurrentMonth() {
109+
const actualValue = datePickerTestsNative.getNativeMonth(this.testView);
110+
const expectedValue = currentDate.getMonth() + 1;
111+
TKUnit.assertEqual(actualValue, expectedValue);
112+
}
113+
114+
public test_WhenCreated_NativeDayIsCurrentDay() {
115+
const actualValue = datePickerTestsNative.getNativeDay(this.testView);;
116+
const expectedValue = currentDate.getDate();
117+
TKUnit.assertEqual(actualValue, expectedValue);
118+
}
119+
102120
public testYearFromLocalToNative() {
103121
const expectedValue = 1980;
104122
this.testView.year = expectedValue;

‎tns-core-modules/ui/date-picker/date-picker.android.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class DatePicker extends DatePickerBase {
5959
picker.setCalendarViewShown(false);
6060
const listener = new DateChangedListener(this);
6161

62-
picker.init(this.year, this.month, this.day, listener);
62+
picker.init(this.year, this.month - 1, this.day, listener);
6363
(<any>picker).listener = listener;
6464
return picker;
6565
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL