Merge pull request #506 from qistoph/dateformat

Dateformat
This commit is contained in:
Michael Teeuw
2016-11-10 19:38:51 +01:00
committed by GitHub
3 changed files with 11 additions and 2 deletions

View File

@@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Added option to show rain amount in the weatherforecast default module
- Add module `updatenotification` to get an update whenever a new version is availabe. [See documentation](https://github.com/MichMich/MagicMirror/tree/develop/modules/default/updatenotification) for more information.
- Add the abilty to set timezone on the date display in the Clock Module
- Ability to set date format in calendar module
### Updated
- Modified translations for Frysk.

View File

@@ -118,6 +118,13 @@ The following properties can be configured:
<br><b>Default value:</b> <code>false</code>
</td>
</tr>
<tr>
<td><code>dateFormat</code></td>
<td>Format to use for the date of events (when using absolute dates)<br>
<br><b>Possible values:</b> See <a href="http://momentjs.com/docs/#/parsing/string-format/">Moment.js formats</a>
<br><b>Default value:</b> <code>MMM Do</code> (e.g. Jan 18th)
</td>
</tr>
<tr>
<td><code>timeFormat</code></td>
<td>Display event times as absolute dates, or relative time<br>

View File

@@ -23,6 +23,7 @@ Module.register("calendar", {
fade: true,
urgency: 7,
timeFormat: "relative",
dateFormat: "MMM Do",
getRelative: 6,
fadePoint: 0.25, // Start on 1/4th of the list.
calendars: [
@@ -175,7 +176,7 @@ Module.register("calendar", {
// This event falls within the config.urgency period that the user has set
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
} else {
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").format("MMM Do"));
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").format(this.config.dateFormat));
}
} else {
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
@@ -205,7 +206,7 @@ Module.register("calendar", {
// This event falls within the config.urgency period that the user has set
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
} else {
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").format("MMM Do"));
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").format(this.config.dateFormat));
}
} else {
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());