mirror of https://github.com/zulip/zulip.git
message_edit_history: Replace date-fns format with Intl.DateTimeFormat.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
64a7810065
commit
b897be76b4
|
@ -1,4 +1,4 @@
|
|||
import {format, isSameDay} from "date-fns";
|
||||
import {isSameDay} from "date-fns";
|
||||
import $ from "jquery";
|
||||
|
||||
import render_message_edit_history from "../templates/message_edit_history.hbs";
|
||||
|
@ -16,6 +16,7 @@ import * as spectators from "./spectators";
|
|||
import * as sub_store from "./sub_store";
|
||||
import * as timerender from "./timerender";
|
||||
import * as ui_report from "./ui_report";
|
||||
import {user_settings} from "./user_settings";
|
||||
|
||||
export function fetch_and_render_message_history(message) {
|
||||
channel.get({
|
||||
|
@ -26,12 +27,15 @@ export function fetch_and_render_message_history(message) {
|
|||
let prev_time = null;
|
||||
let prev_stream_item = null;
|
||||
|
||||
const date_time_format = new Intl.DateTimeFormat(user_settings.default_language, {
|
||||
dateStyle: "long",
|
||||
});
|
||||
for (const [index, msg] of data.message_history.entries()) {
|
||||
// Format times and dates nicely for display
|
||||
const time = new Date(msg.timestamp * 1000);
|
||||
const item = {
|
||||
timestamp: timerender.stringify_time(time),
|
||||
display_date: format(time, "MMMM d, yyyy"),
|
||||
display_date: date_time_format.format(time),
|
||||
show_date_row: prev_time === null || !isSameDay(time, prev_time),
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue