@minibar-app/worldclock 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/main.js +11 -1
- package/manifest.json +1 -1
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -9,6 +9,16 @@ function cityName(zone) {
|
|
|
9
9
|
return zone.split('/').pop().replace(/_/g, ' ');
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
// "GMT+9" / "GMT-4:30": the zone's current offset, so the list reads at a glance.
|
|
13
|
+
function offsetLabel(now, zone) {
|
|
14
|
+
const local = new Date(now.toLocaleString('en-US', { timeZone: zone }));
|
|
15
|
+
const utc = new Date(now.toLocaleString('en-US', { timeZone: 'UTC' }));
|
|
16
|
+
const minutes = Math.round((local - utc) / 60000);
|
|
17
|
+
const sign = minutes < 0 ? '-' : '+';
|
|
18
|
+
const abs = Math.abs(minutes);
|
|
19
|
+
return 'GMT' + sign + Math.floor(abs / 60) + (abs % 60 ? ':' + String(abs % 60).padStart(2, '0') : '');
|
|
20
|
+
}
|
|
21
|
+
|
|
12
22
|
defineMiniApp({
|
|
13
23
|
id: 'app.minibar.community.worldclock',
|
|
14
24
|
|
|
@@ -33,7 +43,7 @@ defineMiniApp({
|
|
|
33
43
|
continue;
|
|
34
44
|
}
|
|
35
45
|
if (!headline) headline = cityName(zone) + ' ' + time;
|
|
36
|
-
const cells = [ui.text(cityName(zone)), ui.spacer()];
|
|
46
|
+
const cells = [ui.text(cityName(zone)), ui.text(offsetLabel(now, zone), { style: 'caption', color: 'secondary' }), ui.spacer()];
|
|
37
47
|
if (weekdayThere !== weekdayHere) cells.push(ui.text(weekdayThere, { style: 'caption' }));
|
|
38
48
|
cells.push(ui.text(time, { style: 'mono' }));
|
|
39
49
|
rows.push(ui.row(cells, { spacing: 8 }));
|
package/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "app.minibar.community.worldclock",
|
|
3
3
|
"name": "World Clock",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"description": "Local time in the cities you care about; the first one is the headline.",
|
|
6
6
|
"author": "Minibar community",
|
|
7
7
|
"homepage": "https://minibar-registry.vercel.app/plugins.html#app.minibar.community.worldclock",
|