mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 15:33:30 +00:00
timerender: Extract new variant of get_full_datetime.
Separating these concepts allows us to provide a much nicer format for contexts where ultra-specific clarification is not a priority. This new variant is currently only used in the scheduled messages UI.
This commit is contained in:
@@ -446,6 +446,18 @@ export function absolute_time(timestamp: number, today = new Date()): string {
|
||||
|
||||
// Pass time_format="time" to not include seconds in the time format.
|
||||
export function get_full_datetime(time: Date, time_format: TimeFormat = "time_sec"): string {
|
||||
const date_string = get_localized_date_or_time_for_format(time, "dayofyear_year");
|
||||
const time_string = get_localized_date_or_time_for_format(time, time_format);
|
||||
return $t({defaultMessage: "{date} at {time}"}, {date: date_string, time: time_string});
|
||||
}
|
||||
|
||||
// Preferred variant for displaying a full datetime to users in
|
||||
// contexts like tooltips, where the time was already displayed to the
|
||||
// user in a less precise format.
|
||||
export function get_full_datetime_clarification(
|
||||
time: Date,
|
||||
time_format: TimeFormat = "time_sec",
|
||||
): string {
|
||||
const locale = get_user_locale();
|
||||
const date_string = time.toLocaleDateString(locale);
|
||||
let time_string = get_localized_date_or_time_for_format(time, time_format);
|
||||
|
||||
Reference in New Issue
Block a user