Replaced substr with substring

proto/trying-alternative-approach
Alex van Andel 2021-12-03 13:19:28 +01:00
parent 6b2a4d00e1
commit 943449ce3d
1 changed files with 3 additions and 3 deletions

View File

@ -42,11 +42,11 @@ const AvailabilityPage = ({ profile, eventType, workingHours }: Props) => {
const dateString = asStringOrNull(router.query.date);
if (dateString) {
// todo some extra validation maybe.
const utcOffsetAsDate = dayjs(dateString.substr(11, 14), "Hmm");
const utcOffsetAsDate = dayjs(dateString.substring(11, 14), "Hmm");
const utcOffset = parseInt(
dateString.substr(10, 1) + (utcOffsetAsDate.hour() * 60 + utcOffsetAsDate.minute())
dateString.substring(10, 1) + (utcOffsetAsDate.hour() * 60 + utcOffsetAsDate.minute())
);
const date = dayjs(dateString.substr(0, 10)).utcOffset(utcOffset, true);
const date = dayjs(dateString.substring(0, 10)).utcOffset(utcOffset, true);
return date.isValid() ? date : null;
}
return null;