mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-22 13:09:26 +00:00
move time into its own file and folder
This commit is contained in:
31
js/time/time.js
Normal file
31
js/time/time.js
Normal file
@@ -0,0 +1,31 @@
|
||||
var time = {
|
||||
timeFormat: config.time.timeFormat || 24,
|
||||
dateLocation: '.date',
|
||||
timeLocation: '.time',
|
||||
updateInterval: 1000,
|
||||
intervalId: null
|
||||
};
|
||||
|
||||
time.updateTime = function () {
|
||||
|
||||
var _now = moment(),
|
||||
_date = _now.format('dddd, LL');
|
||||
|
||||
$(this.dateLocation).html(_date);
|
||||
$(this.timeLocation).html(_now.format(this._timeFormat+':mm[<span class="sec">]ss[</span>]'));
|
||||
|
||||
}
|
||||
|
||||
time.init = function () {
|
||||
|
||||
if (parseInt(time.timeFormat) === 12) {
|
||||
time._timeFormat = 'hh'
|
||||
} else {
|
||||
time._timeFormat = 'HH';
|
||||
}
|
||||
|
||||
this.intervalId = setInterval(function () {
|
||||
this.updateTime();
|
||||
}.bind(this), 1000);
|
||||
|
||||
}
|
Reference in New Issue
Block a user