(config, time)
| 5 | * @returns {string} The formatted time string |
| 6 | */ |
| 7 | const 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 | |
| 29 | if (typeof module !== "undefined") module.exports = { |
| 30 | formatTime |
no outgoing calls
no test coverage detected