mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 07:11:17 +08:00
FEATURE: adds support for seconds in local-dates (#6339)
This commit is contained in:
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
var relativeTime = moment.utc(
|
var relativeTime = moment.utc(
|
||||||
options.date + " " + options.time,
|
options.date + " " + options.time,
|
||||||
"YYYY-MM-DD HH:mm"
|
"YYYY-MM-DD HH:mm:ss"
|
||||||
);
|
);
|
||||||
|
|
||||||
if (options.recurring && relativeTime < moment().utc()) {
|
if (options.recurring && relativeTime < moment().utc()) {
|
||||||
@ -43,7 +43,13 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
var relativeTime = relativeTime.tz(moment.tz.guess());
|
var relativeTime = relativeTime.tz(moment.tz.guess());
|
||||||
if (moment(relativeTime).isSame(moment(), "day")) {
|
if (
|
||||||
|
options.format !== "YYYY-MM-DD HH:mm:ss" &&
|
||||||
|
relativeTime.isBetween(
|
||||||
|
moment().subtract(1, "day"),
|
||||||
|
moment().add(2, "day")
|
||||||
|
)
|
||||||
|
) {
|
||||||
relativeTime = relativeTime.calendar();
|
relativeTime = relativeTime.calendar();
|
||||||
} else {
|
} else {
|
||||||
relativeTime = relativeTime.format(options.format);
|
relativeTime = relativeTime.format(options.format);
|
||||||
|
@ -2,9 +2,9 @@ import computed from "ember-addons/ember-computed-decorators";
|
|||||||
import { observes } from "ember-addons/ember-computed-decorators";
|
import { observes } from "ember-addons/ember-computed-decorators";
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
timeFormat: "HH:mm",
|
timeFormat: "HH:mm:ss",
|
||||||
dateFormat: "YYYY-MM-DD",
|
dateFormat: "YYYY-MM-DD",
|
||||||
dateTimeFormat: "YYYY-MM-DD HH:mm",
|
dateTimeFormat: "YYYY-MM-DD HH:mm:ss",
|
||||||
config: null,
|
config: null,
|
||||||
date: null,
|
date: null,
|
||||||
toDate: null,
|
toDate: null,
|
||||||
|
@ -6,7 +6,7 @@ function addLocalDate(buffer, matches, state) {
|
|||||||
let config = {
|
let config = {
|
||||||
date: null,
|
date: null,
|
||||||
time: null,
|
time: null,
|
||||||
format: "YYYY-MM-DD HH:mm",
|
format: "YYYY-MM-DD HH:mm:ss",
|
||||||
timezones: ""
|
timezones: ""
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ function addLocalDate(buffer, matches, state) {
|
|||||||
.filter(t => t)
|
.filter(t => t)
|
||||||
.map(timezone => {
|
.map(timezone => {
|
||||||
const dateTime = moment
|
const dateTime = moment
|
||||||
.utc(`${config.date} ${config.time}`, "YYYY-MM-DD HH:mm")
|
.utc(`${config.date} ${config.time}`, "YYYY-MM-DD HH:mm:ss")
|
||||||
.tz(timezone)
|
.tz(timezone)
|
||||||
.format(config.format);
|
.format(config.format);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user