Make sure input value is zero padded to parse properly

This commit is contained in:
Eric Eastwood 2022-02-18 12:34:21 -06:00
parent 652b96950b
commit 7d95681611
2 changed files with 7 additions and 6 deletions

View File

@ -14,11 +14,12 @@ async function fetchEventsForTimestamp(roomId, ts) {
const timestampToEventEndpoint = urlJoin(
matrixServerUrl,
`_matrix/client/unstable/org.matrix.msc3030/rooms/${roomId}/timestamp_to_event?ts=${ts}&dir=f`
`_matrix/client/unstable/org.matrix.msc3030/rooms/${roomId}/timestamp_to_event?ts=${ts}&dir=b`
);
const timestampToEventResData = await fetchEndpoint(timestampToEventEndpoint);
const eventIdForTimestamp = timestampToEventResData.event_id;
assert(eventIdForTimestamp);
console.log('eventIdForTimestamp', eventIdForTimestamp);
const contextEndpoint = urlJoin(
matrixServerUrl,

View File

@ -89,7 +89,11 @@ class CalendarView extends TemplateView {
t.input({
type: 'month',
className: { CalendarView_heading_monthInput: true },
value: `${calendarDate.getUTCFullYear()}-${calendarDate.getUTCMonth() + 1}`,
value: `${calendarDate.getUTCFullYear()}-${
// ('0' + '2') -> '02'
// ('0' + '12') -> '12'
('0' + (calendarDate.getUTCMonth() + 1)).slice(-2)
}`,
onChange: (e) => vm.onMonthInputChange(e),
}),
@ -156,10 +160,6 @@ class CalendarView extends TemplateView {
// day number from 0 (monday) to 6 (sunday)
const dayNumber = dayNumberDate.getUTCDay();
console.log(
`dayNumberDate=${dayNumberDate.getUTCDate()} (${dayNumber}) isDayInFuture=${isDayInFuture}, ${dayNumberDate.getTime()}, ${todayTs}`
);
// +1 because we're going from 0-based day to 1-based `grid-column-start`
const gridColumnStart = dayNumber + 1;