MCPcopy
hub / github.com/MagicMirrorOrg/MagicMirror / formatTime

Function formatTime

defaultmodules/utils.js:7–27  ·  view source on GitHub ↗
(config, time)

Source from the content-addressed store, hash-verified

5 * @returns {string} The formatted time string
6 */
7const formatTime = (config, time) => {
8 let date = moment(time);
9
10 if (config.timezone) {
11 date = date.tz(config.timezone);
12 }
13
14 if (config.timeFormat !== 24) {
15 if (config.showPeriod) {
16 if (config.showPeriodUpper) {
17 return date.format("h:mm A");
18 } else {
19 return date.format("h:mm a");
20 }
21 } else {
22 return date.format("h:mm");
23 }
24 }
25
26 return date.format("HH:mm");
27};
28
29if (typeof module !== "undefined") module.exports = {
30 formatTime

Callers 3

getDomFunction · 0.85
addFiltersFunction · 0.85
utils_spec.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected