From 3404ebbbb8bca36d9c2c2cc465345389c1700e1b Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 26 Jun 2017 13:03:03 +0200 Subject: [PATCH] Calender respects timeformat In reference to issue #776, made changes to calendar.js to respect timeformat config option if it is used --- CHANGELOG.md | 1 + modules/default/calendar/calendar.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 709bd73e..ca1c5f29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Fix double message about port when server is starting - Corrected Swedish translations for TODAY/TOMORROW/DAYAFTERTOMORROW. - Removed unused import from js/electron.js +- Made calendar.js respect config.timeFormat irrespecive of locale setting ## [2.1.1] - 2017-04-01 diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 848d163c..9ab864b9 100644 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -69,6 +69,29 @@ Module.register("calendar", { // Set locale. moment.locale(config.language); + switch (config.timeFormat) { + case 12: { + moment.updateLocale(config.language, { + longDateFormat: { + LT: "h:mm A" + } + }); + break; + } + case 24: { + moment.updateLocale(config.language, { + longDateFormat: { + LT: "hh:mm" + } + }); + break; + } + // If config.timeFormat was not given (or has invalid format) default to locale default + default: { + break; + } + } + for (var c in this.config.calendars) { var calendar = this.config.calendars[c]; calendar.url = calendar.url.replace("webcal://", "http://");