mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 20:22:53 +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>
|
||||
</td>
|
||||
</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>
|
||||
</table>
|
||||
|
@ -13,6 +13,8 @@ Module.register("clock",{
|
||||
defaults: {
|
||||
timeFormat: config.timeFormat,
|
||||
displaySeconds: true,
|
||||
showPeriod: true,
|
||||
showPeriodUpper: false,
|
||||
},
|
||||
|
||||
// Define required scripts.
|
||||
@ -55,7 +57,15 @@ Module.register("clock",{
|
||||
if (this.config.timeFormat !== 24) {
|
||||
var now = new Date();
|
||||
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");
|
||||
|
@ -76,6 +76,20 @@ The following properties can be configured:
|
||||
<br><b>Default value:</b> uses value of <i>config.timeFormat</i>
|
||||
</td>
|
||||
</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>
|
||||
<td><code>lang</code></td>
|
||||
<td>The language of the days.<br>
|
||||
@ -140,6 +154,5 @@ The following properties can be configured:
|
||||
}</code>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -17,6 +17,8 @@ Module.register("currentweather",{
|
||||
updateInterval: 10 * 60 * 1000, // every 10 minutes
|
||||
animationSpeed: 1000,
|
||||
timeFormat: config.timeFormat,
|
||||
showPeriod: true,
|
||||
showPeriodUpper: false,
|
||||
lang: config.language,
|
||||
|
||||
initialLoadDelay: 0, // 0 seconds delay
|
||||
@ -209,7 +211,15 @@ Module.register("currentweather",{
|
||||
var timeString = moment(sunriseSunsetDateObject).format('HH:mm');
|
||||
if (this.config.timeFormat !== 24) {
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user