{"id":50797521,"url":"https://github.com/swatchtime/swatch-vanillajs","last_synced_at":"2026-06-12T15:34:11.966Z","repository":{"id":235030951,"uuid":"789936466","full_name":"swatchtime/swatch-vanillajs","owner":"swatchtime","description":"A simple plain vanilla Javascript PWA app which displays Swatch Internet Time in .beats","archived":false,"fork":false,"pushed_at":"2025-11-29T02:10:23.000Z","size":111,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-06-12T15:34:10.888Z","etag":null,"topics":["clock","clocks","javascript","pwa","pwa-app","swatch-internet","swatch-internet-time","vanilla-javascript","vanilla-js"],"latest_commit_sha":null,"homepage":"https://kendawson.online/free/swatch/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swatchtime.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-04-22T00:11:21.000Z","updated_at":"2025-11-29T02:10:26.000Z","dependencies_parsed_at":"2024-04-22T03:27:58.898Z","dependency_job_id":null,"html_url":"https://github.com/swatchtime/swatch-vanillajs","commit_stats":null,"previous_names":["kendawson-online/swatch","swatchtime/swatch-vanillajs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/swatchtime/swatch-vanillajs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swatchtime%2Fswatch-vanillajs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swatchtime%2Fswatch-vanillajs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swatchtime%2Fswatch-vanillajs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swatchtime%2Fswatch-vanillajs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swatchtime","download_url":"https://codeload.github.com/swatchtime/swatch-vanillajs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swatchtime%2Fswatch-vanillajs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34251774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clock","clocks","javascript","pwa","pwa-app","swatch-internet","swatch-internet-time","vanilla-javascript","vanilla-js"],"created_at":"2026-06-12T15:34:11.459Z","updated_at":"2026-06-12T15:34:11.959Z","avatar_url":"https://github.com/swatchtime.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swatch Internet Time: Vanilla JS PWA\n\nversion 0.1.0 \n\nA plain vanilla Javascript PWA app to display the current Swatch Internet Time. This is the \"no frills\" version which just displays the current .beat time with no additional features. \n\n## Screenshot\n\n\u003cimg src=\"https://kendawson.online/img/swatch-time.jpg\" width=\"441\"\u003e\n\nOnline example: https://kendawson.online/free/swatch/\n\n## About\n\nThis version has a service-worker and manifest and can be installed locally as a PWA (on supported devices). \n\nThe primary Javascript function for generating the Swatch Internet Time is as follows:\n\n```\nfunction getSwatchTime() {\n    const d = new Date();\n\n    // Seconds since UTC midnight\n    const utcSeconds = d.getUTCHours() * 3600 + d.getUTCMinutes() * 60 + d.getUTCSeconds();\n\n    // Convert to Biel time (UTC+1, no DST) and wrap to 0-86399\n    const bielSeconds = (utcSeconds + 3600 + 24 * 3600) % (24 * 3600);\n\n    // 1 beat = 86.4 seconds, keep result in 0-999 and pad\n    const beats = String(Math.floor(bielSeconds / 86.4) % 1000).padStart(3, '0');\n\n    // Return string with current Swatch time (e.g. @042)\n    return `@${beats}`;\n}\n```\n\nThe magic explained:\n\n```\nconst beats = String(Math.floor(bielSeconds / 86.4) % 1000).padStart(3, '0');\n```\n\n## Note: Rounding and display (important)\n\nIf you display centibeats (two decimals) be careful when rounding. A raw beat value like `999.995` can round to `1000.00` which is invalid for display — the correct display is `000.00`. To avoid a transient `1000.00` flash, round then wrap values \u003e=1000 back into range before formatting:\n\n```js\nconst rawBeats = bielSeconds / 86.4;\nlet rounded = Math.round(rawBeats * 100) / 100;\nif (rounded \u003e= 1000) rounded = rounded - 1000;\nconst display = rounded.toFixed(2); // safe to show\n```\n\n\n - `bielSeconds` is the number of seconds since midnight in Biel time (UTC+1, no DST), computed from UTC time.\n - Divide by 86.4 to convert seconds to Swatch beats (86400 seconds/day =\u003e 1000 beats).\n - `Math.floor(...)` gives the integer beat number.\n - `% 1000` ensures the beat wraps into the 0-999 range.\n - `.padStart(3, '0')` pads the number with leading zeros to always produce 3 digits.\n\n### Links:\n\n- About Swatch Internet Time: https://www.swatch.com/en-us/internet-time.html \n- Github: https://github.com/swatchtime\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswatchtime%2Fswatch-vanillajs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswatchtime%2Fswatch-vanillajs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswatchtime%2Fswatch-vanillajs/lists"}