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( const timestampToEventEndpoint = urlJoin(
matrixServerUrl, 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 timestampToEventResData = await fetchEndpoint(timestampToEventEndpoint);
const eventIdForTimestamp = timestampToEventResData.event_id; const eventIdForTimestamp = timestampToEventResData.event_id;
assert(eventIdForTimestamp); assert(eventIdForTimestamp);
console.log('eventIdForTimestamp', eventIdForTimestamp);
const contextEndpoint = urlJoin( const contextEndpoint = urlJoin(
matrixServerUrl, matrixServerUrl,

View File

@ -89,7 +89,11 @@ class CalendarView extends TemplateView {
t.input({ t.input({
type: 'month', type: 'month',
className: { CalendarView_heading_monthInput: true }, 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), onChange: (e) => vm.onMonthInputChange(e),
}), }),
@ -156,10 +160,6 @@ class CalendarView extends TemplateView {
// day number from 0 (monday) to 6 (sunday) // day number from 0 (monday) to 6 (sunday)
const dayNumber = dayNumberDate.getUTCDay(); 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` // +1 because we're going from 0-based day to 1-based `grid-column-start`
const gridColumnStart = dayNumber + 1; const gridColumnStart = dayNumber + 1;