From d971b36026805828a6f88d0ce37cdcafa467942d Mon Sep 17 00:00:00 2001 From: roanster007 Date: Sat, 3 Feb 2024 19:51:10 +0530 Subject: [PATCH] timerender: Extract get_current_time_to_hour helper. We will reuse this in the next commit. --- web/src/timerender.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web/src/timerender.ts b/web/src/timerender.ts index ce2e0781fe..037be40a60 100644 --- a/web/src/timerender.ts +++ b/web/src/timerender.ts @@ -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;