@minibar-app/worldclock 0.0.0-stage → 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 ADDED
@@ -0,0 +1,57 @@
1
+ // World Clock — the community plugin that doubles as the submission pipeline's
2
+ // smoke test: no permissions, one setting, Intl for the time zones.
3
+ const LABELS = {
4
+ en: { addZones: 'Add time zones such as Asia/Tokyo in the settings.', setZones: 'Set time zones', unknownZone: 'unknown time zone' },
5
+ zh: { addZones: '在设置里添加时区,例如 Asia/Tokyo。', setZones: '设置时区', unknownZone: '未知时区' },
6
+ };
7
+
8
+ function cityName(zone) {
9
+ return zone.split('/').pop().replace(/_/g, ' ');
10
+ }
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
+
22
+ defineMiniApp({
23
+ id: 'app.minibar.community.worldclock',
24
+
25
+ render(ctx) {
26
+ const ui = ctx.ui;
27
+ const t = ctx.i18n(LABELS);
28
+ const zones = String(ctx.settings.get('zones', '')).split(',').map((z) => z.trim()).filter(Boolean).slice(0, 8);
29
+ if (!zones.length) {
30
+ return { title: null, body: [ui.text(t.addZones), ui.button(t.setZones, '$openSettings')] };
31
+ }
32
+ const now = new Date();
33
+ const weekdayHere = new Intl.DateTimeFormat('en-US', { weekday: 'short' }).format(now);
34
+ const rows = [];
35
+ let headline = null;
36
+ for (const zone of zones) {
37
+ let time, weekdayThere;
38
+ try {
39
+ time = new Intl.DateTimeFormat(ctx.locale, { hour: 'numeric', minute: '2-digit', timeZone: zone }).format(now);
40
+ weekdayThere = new Intl.DateTimeFormat('en-US', { weekday: 'short', timeZone: zone }).format(now);
41
+ } catch (e) {
42
+ rows.push(ui.keyValue(zone, t.unknownZone, { color: 'warning' }));
43
+ continue;
44
+ }
45
+ if (!headline) headline = cityName(zone) + ' ' + time;
46
+ const cells = [ui.text(cityName(zone)), ui.text(offsetLabel(now, zone), { style: 'caption', color: 'secondary' }), ui.spacer()];
47
+ if (weekdayThere !== weekdayHere) cells.push(ui.text(weekdayThere, { style: 'caption' }));
48
+ cells.push(ui.text(time, { style: 'mono' }));
49
+ rows.push(ui.row(cells, { spacing: 8 }));
50
+ }
51
+ return {
52
+ title: headline ? { text: headline, icon: 'globe' } : null,
53
+ body: [ui.column(rows, { spacing: 6 })],
54
+ refreshIn: Math.max(1, 60 - now.getSeconds()),
55
+ };
56
+ },
57
+ });
package/manifest.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "id": "app.minibar.community.worldclock",
3
+ "name": "World Clock",
4
+ "version": "1.0.3",
5
+ "description": "Local time in the cities you care about; the first one is the headline.",
6
+ "author": "Minibar community",
7
+ "homepage": "https://minibar-registry.vercel.app/plugins.html#app.minibar.community.worldclock",
8
+ "icon": "globe",
9
+ "category": "life",
10
+ "refreshInterval": 60,
11
+ "minHostVersion": "0.5.0",
12
+ "settings": [
13
+ { "key": "zones", "type": "text", "label": "Time zones (comma separated)", "placeholder": "America/New_York, Europe/London, Asia/Tokyo",
14
+ "default": "America/New_York, Europe/London, Asia/Tokyo", "description": "IANA names such as Asia/Shanghai or Europe/Berlin; up to 8." }
15
+ ],
16
+ "localizations": {
17
+ "zh-Hans": {
18
+ "name": "世界时钟",
19
+ "description": "你关心的城市的当地时间,第一个城市显示在头条。",
20
+ "settings": { "zones": { "label": "时区(逗号分隔)", "description": "IANA 名称,如 Asia/Shanghai、Europe/Berlin;最多 8 个。" } }
21
+ }
22
+ }
23
+ }
package/package.json CHANGED
@@ -1,6 +1,13 @@
1
1
  {
2
2
  "name": "@minibar-app/worldclock",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.3",
4
+ "description": "Local time in the cities you care about; the first one is the headline.",
5
+ "keywords": [
6
+ "minibar-plugin"
7
+ ],
8
+ "license": "UNLICENSED",
9
+ "minibar": {
10
+ "id": "app.minibar.community.worldclock",
11
+ "minHostVersion": "0.5.0"
12
+ }
13
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.