From 4e5df39f0eaf07d9a828716e096f979cc474521f Mon Sep 17 00:00:00 2001
From: Julian Liu <wlootlxt123@gmail.com>
Date: Tue, 12 May 2020 04:51:48 +0800
Subject: [PATCH] flarum/core: Localized date format
---
vendor/flarum/core/js/src/common/utils/humanTime.js | 7 +++----
.../core/js/src/forum/components/PostStreamScrubber.js | 2 +-
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/vendor/flarum/core/js/src/common/utils/humanTime.js b/vendor/flarum/core/js/src/common/utils/humanTime.js
index a06e16a..6a2fd72 100644
--- a/vendor/flarum/core/js/src/common/utils/humanTime.js
+++ b/vendor/flarum/core/js/src/common/utils/humanTime.js
@@ -17,14 +17,13 @@ export default function humanTime(time) {
}
const day = 864e5;
- const diff = m.diff(moment());
+ const diff = m.diff(now);
let ago = null;
// If this date was more than a month ago, we'll show the name of the month
- // in the string. If it wasn't this year, we'll show the year as well.
if (diff < -30 * day) {
- if (m.year() === moment().year()) {
- ago = m.format('D MMM');
+ if (m.year() === now.year()) {
+ ago = m.format('ll').replace(new RegExp('[^.]?' + m.format('YYYY') + '.?'), '');
} else {
ago = m.format('ll');
}
diff --git a/vendor/flarum/core/js/src/forum/components/PostStreamScrubber.js b/vendor/flarum/core/js/src/forum/components/PostStreamScrubber.js
index af47373..6970396 100644
--- a/vendor/flarum/core/js/src/forum/components/PostStreamScrubber.js
+++ b/vendor/flarum/core/js/src/forum/components/PostStreamScrubber.js
@@ -239,7 +239,7 @@ export default class PostStreamScrubber extends Component {
this.index = index;
this.visible = visible;
- this.description = period ? moment(period).format('MMMM YYYY') : '';
+ this.description = period ? moment(period).format('l') : '';
}
config(isInitialized, context) {
按这样改可以保留官方原意 – 必要时省略年份