From acd1693dac1bff6ff50250d942134bc48a27ff14 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 25 Jun 2018 22:16:07 +0200 Subject: [PATCH] FEATURE: simplifies the same day hour to hour use case in local dates --- .../discourse-local-dates-create-form.js.es6 | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6 b/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6 index 2027f844171..75170bb847c 100644 --- a/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6 +++ b/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6 @@ -82,10 +82,15 @@ export default Ember.Component.extend({ "timezones" ) _setConfig() { + const toTime = this.get("toTime"); + + if (toTime && !this.get("toDate")) { + this.set("toDate", moment().format(this.dateFormat)); + } + const date = this.get("date"); const toDate = this.get("toDate"); const time = this.get("time"); - const toTime = this.get("toTime"); const recurring = this.get("recurring"); const format = this.get("format"); const timezones = this.get("timezones"); @@ -125,7 +130,7 @@ export default Ember.Component.extend({ config.toTime = toDateTime.format(this.timeFormat); } - if (!time && !toTime && ["LLL", "LLLL", "LLLLL"].includes(format)) { + if (!time && !toTime && this.get("formats").includes(format)) { config.format = "LL"; } @@ -133,6 +138,15 @@ export default Ember.Component.extend({ config.toDateTime = toDateTime; } + if ( + time && + toTime && + date === toDate && + this.get("formats").includes(format) + ) { + config.format = "LT"; + } + this.set("config", config); },