mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 15:33:30 +00:00
timerender: Extract get_current_time_to_hour helper.
We will reuse this in the next commit.
This commit is contained in:
@@ -423,6 +423,12 @@ export function get_full_time(timestamp: number): string {
|
||||
return formatISO(timestamp * 1000);
|
||||
}
|
||||
|
||||
function get_current_time_to_hour(): Date {
|
||||
const timestamp = new Date();
|
||||
timestamp.setMinutes(0, 0);
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
export function get_timestamp_for_flatpickr(timestring: string): Date {
|
||||
let timestamp;
|
||||
try {
|
||||
@@ -432,8 +438,7 @@ export function get_timestamp_for_flatpickr(timestring: string): Date {
|
||||
} finally {
|
||||
// Otherwise, default to showing the current time to the hour.
|
||||
if (!timestamp || !isValid(timestamp)) {
|
||||
timestamp = new Date();
|
||||
timestamp.setMinutes(0, 0);
|
||||
timestamp = get_current_time_to_hour();
|
||||
}
|
||||
}
|
||||
return timestamp;
|
||||
|
||||
Reference in New Issue
Block a user