Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: simplifies the same day hour to hour use case in local dates

Joffrey JAFFEUXacd1693dac1b
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);
},