Skip to content

Commit 1ededb4

Browse files
Add istanbul ignore comment for untestable catch block
1 parent 19df127 commit 1ededb4

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/date_utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function getDateFnsTz(): DateFnsTz | null {
115115
// eslint-disable-next-line @typescript-eslint/no-require-imports
116116
dateFnsTz = require("date-fns-tz") as DateFnsTz;
117117
} catch {
118-
// date-fns-tz is not installed
118+
/* istanbul ignore next - only executes when date-fns-tz is not installed */
119119
dateFnsTz = null;
120120
}
121121

src/index.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,14 @@ export class DatePicker extends Component<DatePickerProps, DatePickerState> {
10791079
changedStartDate = fromZonedTime(changedStartDate, timeZone);
10801080
}
10811081
onChange?.(
1082-
[changedStartDate, endDate ? (timeZone ? fromZonedTime(endDate, timeZone) : endDate) : null],
1082+
[
1083+
changedStartDate,
1084+
endDate
1085+
? timeZone
1086+
? fromZonedTime(endDate, timeZone)
1087+
: endDate
1088+
: null,
1089+
],
10831090
undefined,
10841091
);
10851092
}
@@ -1098,7 +1105,14 @@ export class DatePicker extends Component<DatePickerProps, DatePickerState> {
10981105
changedEndDate = fromZonedTime(changedEndDate, timeZone);
10991106
}
11001107
onChange?.(
1101-
[startDate ? (timeZone ? fromZonedTime(startDate, timeZone) : startDate) : null, changedEndDate],
1108+
[
1109+
startDate
1110+
? timeZone
1111+
? fromZonedTime(startDate, timeZone)
1112+
: startDate
1113+
: null,
1114+
changedEndDate,
1115+
],
11021116
undefined,
11031117
);
11041118
}
@@ -1134,7 +1148,10 @@ export class DatePicker extends Component<DatePickerProps, DatePickerState> {
11341148
changedEndDate = fromZonedTime(changedEndDate, timeZone);
11351149
}
11361150
onChange?.(
1137-
[timeZone ? fromZonedTime(startDate, timeZone) : startDate, changedEndDate],
1151+
[
1152+
timeZone ? fromZonedTime(startDate, timeZone) : startDate,
1153+
changedEndDate,
1154+
],
11381155
undefined,
11391156
);
11401157
} else {
@@ -1153,7 +1170,7 @@ export class DatePicker extends Component<DatePickerProps, DatePickerState> {
11531170
const selected = this.props.selected
11541171
? this.props.selected
11551172
: this.getPreSelection();
1156-
const changedDate = this.props.selected
1173+
let changedDate = this.props.selected
11571174
? time
11581175
: setTime(selected, {
11591176
hour: getHours(time),

0 commit comments

Comments
 (0)