FEATURE: adds support for seconds in local-dates (#6339)

This commit is contained in:
Joffrey JAFFEUX 2018-08-30 12:38:05 +02:00 committed by GitHub
parent d40d241e72
commit 3ed9533066
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

View File

@ -13,7 +13,7 @@
var relativeTime = moment.utc(
options.date + " " + options.time,
"YYYY-MM-DD HH:mm"
"YYYY-MM-DD HH:mm:ss"
);
if (options.recurring && relativeTime < moment().utc()) {
@ -43,7 +43,13 @@
});
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();
} else {
relativeTime = relativeTime.format(options.format);

View File

@ -2,9 +2,9 @@ import computed from "ember-addons/ember-computed-decorators";
import { observes } from "ember-addons/ember-computed-decorators";
export default Ember.Component.extend({
timeFormat: "HH:mm",
timeFormat: "HH:mm:ss",
dateFormat: "YYYY-MM-DD",
dateTimeFormat: "YYYY-MM-DD HH:mm",
dateTimeFormat: "YYYY-MM-DD HH:mm:ss",
config: null,
date: null,
toDate: null,

View File

@ -6,7 +6,7 @@ function addLocalDate(buffer, matches, state) {
let config = {
date: null,
time: null,
format: "YYYY-MM-DD HH:mm",
format: "YYYY-MM-DD HH:mm:ss",
timezones: ""
};
@ -44,7 +44,7 @@ function addLocalDate(buffer, matches, state) {
.filter(t => t)
.map(timezone => {
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)
.format(config.format);