Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
Revert "time_widget: Make the generated time string more readable."
Anders Kaseorg42fa62e563a2
diff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.jsindex 6e83f49ac99..238ba4baee2 100644--- a/static/js/composebox_typeahead.js+++ b/static/js/composebox_typeahead.js@@ -1,4 +1,4 @@-import {format} from "date-fns";+import {formatISO} from "date-fns";import ConfirmDatePlugin from "flatpickr/dist/plugins/confirmDate/confirmDate";import $ from "jquery";import _ from "lodash";@@ -778,7 +778,7 @@ const show_flatpickr = (element, callback, default_timestamp) => {plugins: [new ConfirmDatePlugin({})],positionElement: element,dateFormat: "Z",- formatDate: (date) => format(date, "yyyy-MM-dd|HH:mm:ss|'UTC'xxx"),+ formatDate: (date) => formatISO(date),});const container = $($(instance.innerContainer).parent());container.on("click", ".flatpickr-calendar", (e) => {diff --git a/static/js/markdown.js b/static/js/markdown.jsindex 7f0ce5c50a4..67a57a66ead 100644--- a/static/js/markdown.js+++ b/static/js/markdown.js@@ -346,14 +346,7 @@ function handleEmoji(emoji_name) {function handleTimestamp(time) {let timeobject;if (Number.isNaN(Number(time))) {- // Check if the time string is of the new more-readable format.- if (time.includes("|UTC")) {- // Remove and replace the non-standard characters with the ISO ones.- const standard_format_time = time.replace("|UTC", "").replace(/\|/g, "T");- timeobject = new Date(standard_format_time);- } else {- timeobject = new Date(time); // not a Unix timestamp- }+ timeobject = new Date(time); // not a Unix timestamp} else {// JavaScript dates are in milliseconds, Unix timestamps are in secondstimeobject = new Date(time * 1000);diff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.pyindex d6de4252a1d..f55714c89ac 100644--- a/zerver/lib/markdown/__init__.py+++ b/zerver/lib/markdown/__init__.py@@ -1369,13 +1369,7 @@ class Timestamp(markdown.inlinepatterns.Pattern):time_input_string = match.group("time")timestamp = Nonetry:- # Check if the time string is of the new more-readable format.- if "|UTC" in time_input_string:- # Remove and replace the non-standard characters with the ISO ones.- standard_format_time = time_input_string.replace("|", "T", 1).replace("|UTC", "")- timestamp = dateutil.parser.parse(standard_format_time, tzinfos=common_timezones)- else:- timestamp = dateutil.parser.parse(time_input_string, tzinfos=common_timezones)+ timestamp = dateutil.parser.parse(time_input_string, tzinfos=common_timezones)except ValueError:try:timestamp = datetime.datetime.fromtimestamp(float(time_input_string))diff --git a/zerver/tests/fixtures/markdown_test_cases.json b/zerver/tests/fixtures/markdown_test_cases.jsonindex d1c03fcf1e1..c449e0ed5a0 100644--- a/zerver/tests/fixtures/markdown_test_cases.json+++ b/zerver/tests/fixtures/markdown_test_cases.json@@ -790,19 +790,6 @@"expected_output": "<p>Let's meet at <time datetime=\"2017-06-05T22:30:00Z\">1496701800</time>.</p>","text_content": "Let's meet at 1496701800."},- {- "name": "timestamp_new_format",- "input": "<time:2021-08-02|14:03:00|UTC+05:30>",- "expected_output": "<p><time datetime=\"2021-08-02T08:33:00Z\">2021-08-02|14:03:00|UTC+05:30</time></p>",- "text_content": "2021-08-02|14:03:00|UTC+05:30"- },- {- "name": "timestamp_without_utc",- "input": "<time:2021-08-02|14:03:00|+05:30>",- "expected_output": "<p><span class=\"timestamp-error\">Invalid time format: 2021-08-02|14:03:00|+05:30</span></p>",- "marked_expected_output": "<p><span>2021-08-02|14:03:00|+05:30</span></p>",- "text_content": "Invalid time format: 2021-08-02|14:03:00|+05:30"- },{"name": "tex_inline","input": "$$1 \\oplus 0 = 1$$",