scheduled_message: Fix i18n for scheduled time.

This commit is contained in:
Tim Abbott 2023-04-28 16:29:13 -07:00
parent d41f12495d
commit d42ac60d61
3 changed files with 8 additions and 3 deletions

View File

@ -44,6 +44,7 @@ import * as settings_data from "./settings_data";
import * as starred_messages from "./starred_messages";
import * as starred_messages_ui from "./starred_messages_ui";
import * as stream_popover from "./stream_popover";
import * as timerender from "./timerender";
import {parse_html} from "./ui_util";
import * as unread_ops from "./unread_ops";
import {user_settings} from "./user_settings";
@ -92,7 +93,7 @@ export function get_formatted_selected_send_later_time() {
if (!selected_send_later_time) {
return undefined;
}
return format(new Date(selected_send_later_time), "MMM d yyyy 'at' h:mm a");
return timerender.get_full_datetime(selected_send_later_time, "time");
}
export function reset_selected_schedule_time() {

View File

@ -444,10 +444,11 @@ export function absolute_time(timestamp: number, today = new Date()): string {
);
}
export function get_full_datetime(time: 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 locale = get_user_locale();
const date_string = time.toLocaleDateString(locale);
let time_string = get_localized_date_or_time_for_format(time, "time_sec");
let time_string = get_localized_date_or_time_for_format(time, time_format);
const tz_offset_str = get_tz_with_UTC_offset(time);

View File

@ -448,6 +448,9 @@ run_test("get_full_datetime", () => {
let expected = "translated: 5/18/2017 at 9:12:53 PM UTC";
assert.equal(timerender.get_full_datetime(time), expected);
expected = "translated: 5/18/2017 at 9:12 PM UTC";
assert.equal(timerender.get_full_datetime(time, "time"), expected);
// test 24 hour time setting.
user_settings.twenty_four_hour_time = true;
expected = "translated: 5/18/2017 at 21:12:53 UTC";