mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-29 12:39:45 +00:00
Merge pull request #198 from Intecpsp/v2-beta
Allow 12 hour period config
This commit is contained in:
commit
a7948ee1da
@ -45,5 +45,19 @@ The following properties can be configured:
|
|||||||
<br><b>Default value:</b> <code>true</code>
|
<br><b>Default value:</b> <code>true</code>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>showPeriod</code></td>
|
||||||
|
<td>Show the period (am/pm) with 12 hour format<br>
|
||||||
|
<br><b>Possible values:</b> <code>true</code> or <code>false</code>
|
||||||
|
<br><b>Default value:</b> <code>true</code>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>showPeriodUpper</code></td>
|
||||||
|
<td>Show the period (AM/PM) with 12 hour format as uppercase<br>
|
||||||
|
<br><b>Possible values:</b> <code>true</code> or <code>false</code>
|
||||||
|
<br><b>Default value:</b> <code>false</code>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -13,6 +13,8 @@ Module.register("clock",{
|
|||||||
defaults: {
|
defaults: {
|
||||||
timeFormat: config.timeFormat,
|
timeFormat: config.timeFormat,
|
||||||
displaySeconds: true,
|
displaySeconds: true,
|
||||||
|
showPeriod: true,
|
||||||
|
showPeriodUpper: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Define required scripts.
|
// Define required scripts.
|
||||||
@ -55,7 +57,15 @@ Module.register("clock",{
|
|||||||
if (this.config.timeFormat !== 24) {
|
if (this.config.timeFormat !== 24) {
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
var hours = now.getHours() % 12 || 12;
|
var hours = now.getHours() % 12 || 12;
|
||||||
timeString = hours + moment().format(':mm a');
|
if (this.config.showPeriod) {
|
||||||
|
if (this.config.showPeriodUpper) {
|
||||||
|
timeString = hours + moment().format(':mm A');
|
||||||
|
} else {
|
||||||
|
timeString = hours + moment().format(':mm a');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
timeString = hours + moment().format(':mm');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dateWrapper.innerHTML = moment().format("dddd, LL");
|
dateWrapper.innerHTML = moment().format("dddd, LL");
|
||||||
|
@ -76,6 +76,20 @@ The following properties can be configured:
|
|||||||
<br><b>Default value:</b> uses value of <i>config.timeFormat</i>
|
<br><b>Default value:</b> uses value of <i>config.timeFormat</i>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>showPeriod</code></td>
|
||||||
|
<td>Show the period (am/pm) with 12 hour format<br>
|
||||||
|
<br><b>Possible values:</b> <code>true</code> or <code>false</code>
|
||||||
|
<br><b>Default value:</b> <code>true</code>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>showPeriodUpper</code></td>
|
||||||
|
<td>Show the period (AM/PM) with 12 hour format as uppercase<br>
|
||||||
|
<br><b>Possible values:</b> <code>true</code> or <code>false</code>
|
||||||
|
<br><b>Default value:</b> <code>false</code>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>lang</code></td>
|
<td><code>lang</code></td>
|
||||||
<td>The language of the days.<br>
|
<td>The language of the days.<br>
|
||||||
@ -140,6 +154,5 @@ The following properties can be configured:
|
|||||||
}</code>
|
}</code>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -17,6 +17,8 @@ Module.register("currentweather",{
|
|||||||
updateInterval: 10 * 60 * 1000, // every 10 minutes
|
updateInterval: 10 * 60 * 1000, // every 10 minutes
|
||||||
animationSpeed: 1000,
|
animationSpeed: 1000,
|
||||||
timeFormat: config.timeFormat,
|
timeFormat: config.timeFormat,
|
||||||
|
showPeriod: true,
|
||||||
|
showPeriodUpper: false,
|
||||||
lang: config.language,
|
lang: config.language,
|
||||||
|
|
||||||
initialLoadDelay: 0, // 0 seconds delay
|
initialLoadDelay: 0, // 0 seconds delay
|
||||||
@ -209,7 +211,15 @@ Module.register("currentweather",{
|
|||||||
var timeString = moment(sunriseSunsetDateObject).format('HH:mm');
|
var timeString = moment(sunriseSunsetDateObject).format('HH:mm');
|
||||||
if (this.config.timeFormat !== 24) {
|
if (this.config.timeFormat !== 24) {
|
||||||
var hours = sunriseSunsetDateObject.getHours() % 12 || 12;
|
var hours = sunriseSunsetDateObject.getHours() % 12 || 12;
|
||||||
timeString = hours + moment(sunriseSunsetDateObject).format(':mm a');
|
if (this.config.showPeriod) {
|
||||||
|
if (this.config.showPeriodUpper) {
|
||||||
|
timeString = hours + moment(sunriseSunsetDateObject).format(':mm A');
|
||||||
|
} else {
|
||||||
|
timeString = hours + moment(sunriseSunsetDateObject).format(':mm a');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
timeString = hours + moment(sunriseSunsetDateObject).format(':mm');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sunriseSunsetTime = timeString;
|
this.sunriseSunsetTime = timeString;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user