Refactor formatTime into util class (#3073)

While looking at https://github.com/MichMich/MagicMirror/pull/3070 I
noticed that the weather and clock module do some formatTime stuff, so
why not use a common function for that?

---------

Co-authored-by: veeck <michael@veeck.de>
This commit is contained in:
Veeck
2023-04-07 23:11:54 +02:00
committed by GitHub
parent 2c7beeaaaf
commit 32192d1698
8 changed files with 129 additions and 40 deletions

View File

@@ -7,7 +7,7 @@ describe("Weather utils tests", () => {
const units = ["mm", "cm"];
for (let i = 0; i < values.length; i++) {
var result = weather.convertPrecipitationUnit(values[i], units[i], undefined);
const result = weather.convertPrecipitationUnit(values[i], units[i], undefined);
expect(result).toBe(`${values[i].toFixed(2)} ${units[i]}`);
}
});
@@ -17,7 +17,7 @@ describe("Weather utils tests", () => {
const units = ["mm", "cm"];
for (let i = 0; i < values.length; i++) {
var result = weather.convertPrecipitationUnit(values[i], units[i], "metric");
const result = weather.convertPrecipitationUnit(values[i], units[i], "metric");
expect(result).toBe(`${values[i].toFixed(2)} ${units[i]}`);
}
});
@@ -26,7 +26,7 @@ describe("Weather utils tests", () => {
const values = [1, 2];
for (let i = 0; i < values.length; i++) {
var result = weather.convertPrecipitationUnit(values[i], undefined, "metric");
const result = weather.convertPrecipitationUnit(values[i], undefined, "metric");
expect(result).toBe(`${values[i].toFixed(2)} mm`);
}
});
@@ -37,7 +37,7 @@ describe("Weather utils tests", () => {
const expectedValues = [0.04, 0.79];
for (let i = 0; i < values.length; i++) {
var result = weather.convertPrecipitationUnit(values[i], units[i], "imperial");
const result = weather.convertPrecipitationUnit(values[i], units[i], "imperial");
expect(result).toBe(`${expectedValues[i]} in`);
}
});