Prevent future date selection in jump to date (#10419)
You can still type in whatever date you want (native date input behavior) but the UI picker has future dates disabled. Fix https://github.com/vector-im/element-web/issues/20800
This commit is contained in:
parent
3eb6a55b93
commit
ed88e0cdce
5 changed files with 113 additions and 5 deletions
|
@ -102,6 +102,21 @@ export function formatFullDate(date: Date, showTwelveHour = false, showSeconds =
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats dates to be compatible with attributes of a `<input type="date">`. Dates
|
||||
* should be formatted like "2020-06-23" (formatted according to ISO8601)
|
||||
*
|
||||
* @param date The date to format.
|
||||
* @returns The date string in ISO8601 format ready to be used with an `<input>`
|
||||
*/
|
||||
export function formatDateForInput(date: Date): string {
|
||||
const year = `${date.getFullYear()}`.padStart(4, "0");
|
||||
const month = `${date.getMonth() + 1}`.padStart(2, "0");
|
||||
const day = `${date.getDate()}`.padStart(2, "0");
|
||||
const dateInputValue = `${year}-${month}-${day}`;
|
||||
return dateInputValue;
|
||||
}
|
||||
|
||||
export function formatFullTime(date: Date, showTwelveHour = false): string {
|
||||
if (showTwelveHour) {
|
||||
return twelveHourTime(date, true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue