mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 03:39:55 +00:00
add support to enable set timezone for show in clock module.
This commit is contained in:
parent
b8167f89e5
commit
95f1382fbf
@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- Added CII Badge (we are compliant with the CII Best Practices)
|
||||
- Add support for doing http basic auth when loading calendars
|
||||
- Add the abilty to turn off and on the date display in the Clock Module
|
||||
- Add the abilty to set timezone on the date display in the Clock Module
|
||||
|
||||
### Fixed
|
||||
- Fix typo in installer.
|
||||
|
@ -115,5 +115,13 @@ The following properties can be configured:
|
||||
<br><b>Default value:</b> <code>top</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>timezone</code></td>
|
||||
<td>Specific a timezone to show clock.<br>
|
||||
<br><b>Possible examples values:</b> <code>America/New_York</code>, <code>America/Santiago</code>, <code>Etc/GMT+10</code>
|
||||
<br><b>Default value:</b> <code>none</code>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
|
@ -23,10 +23,11 @@ Module.register("clock",{
|
||||
analogPlacement: 'bottom', // options: 'top', 'bottom', 'left', 'right'
|
||||
analogShowDate: 'top', // options: false, 'top', or 'bottom'
|
||||
secondsColor: '#888888',
|
||||
timezone: null,
|
||||
},
|
||||
// Define required scripts.
|
||||
getScripts: function() {
|
||||
return ["moment.js"];
|
||||
return ["moment.js", "moment-timezone.js"];
|
||||
},
|
||||
// Define styles.
|
||||
getStyles: function() {
|
||||
@ -69,10 +70,14 @@ Module.register("clock",{
|
||||
// So we need to generate the timestring manually.
|
||||
// See issue: https://github.com/MichMich/MagicMirror/issues/181
|
||||
var timeString;
|
||||
var now = moment();
|
||||
if (this.config.timezone) {
|
||||
now.tz(this.config.timezone);
|
||||
}
|
||||
if (this.config.clockBold === true) {
|
||||
timeString = moment().format("HH[<span class=\"bold\">]mm[</span>]");
|
||||
timeString = now.format("HH[<span class=\"bold\">]mm[</span>]");
|
||||
} else {
|
||||
timeString = moment().format("HH:mm");
|
||||
timeString = now.format("HH:mm");
|
||||
}
|
||||
|
||||
if (this.config.timeFormat !== 24) {
|
||||
@ -80,21 +85,21 @@ Module.register("clock",{
|
||||
// var hours = now.getHours() % 12 || 12;
|
||||
if (this.config.clockBold === true) {
|
||||
//timeString = hours + moment().format("[<span class=\"bold\">]mm[</span>]");
|
||||
timeString = moment().format("h[<span class=\"bold\">]mm[</span>]");
|
||||
timeString = now.format("h[<span class=\"bold\">]mm[</span>]");
|
||||
} else {
|
||||
//timeString = hours + moment().format(":mm");
|
||||
timeString = moment().format("h:mm");
|
||||
timeString = now.format("h:mm");
|
||||
}
|
||||
}
|
||||
if(this.config.showDate){
|
||||
dateWrapper.innerHTML = moment().format("dddd, LL");
|
||||
dateWrapper.innerHTML = now.format("dddd, LL");
|
||||
}
|
||||
timeWrapper.innerHTML = timeString;
|
||||
secondsWrapper.innerHTML = moment().format("ss");
|
||||
secondsWrapper.innerHTML = now.format("ss");
|
||||
if (this.config.showPeriodUpper) {
|
||||
periodWrapper.innerHTML = moment().format("A");
|
||||
periodWrapper.innerHTML = now.format("A");
|
||||
} else {
|
||||
periodWrapper.innerHTML = moment().format("a");
|
||||
periodWrapper.innerHTML = now.format("a");
|
||||
}
|
||||
if (this.config.displaySeconds) {
|
||||
timeWrapper.appendChild(secondsWrapper);
|
||||
@ -117,8 +122,11 @@ Module.register("clock",{
|
||||
// If it isn't 'digital', then an 'analog' clock was also requested
|
||||
|
||||
// Calculate the degree offset for each hand of the clock
|
||||
var now = moment(),
|
||||
second = now.seconds() * 6,
|
||||
var now = moment();
|
||||
if (this.config.timezone) {
|
||||
now.tz(this.config.timezone);
|
||||
}
|
||||
var second = now.seconds() * 6,
|
||||
minute = now.minute() * 6 + second / 60,
|
||||
hour = ((now.hours() % 12) / 12) * 360 + 90 + minute / 12;
|
||||
|
||||
@ -227,4 +235,4 @@ Module.register("clock",{
|
||||
// Return the wrapper to the dom.
|
||||
return wrapper;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
1197
vendor/moment/moment-timezone.js
vendored
Normal file
1197
vendor/moment/moment-timezone.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
vendor/vendor.js
vendored
1
vendor/vendor.js
vendored
@ -9,6 +9,7 @@
|
||||
|
||||
var vendor = {
|
||||
'moment.js' : 'moment/moment-with-locales.js',
|
||||
'moment-timezone.js' : 'moment/moment-timezone.js',
|
||||
'weather-icons.css': 'weather-icons/css/weather-icons.css',
|
||||
'weather-icons-wind.css': 'weather-icons/css/weather-icons-wind.css',
|
||||
'font-awesome.css': 'font-awesome-4.5.0/css/font-awesome.min.css'
|
||||
|
Loading…
x
Reference in New Issue
Block a user