{"id":50797520,"url":"https://github.com/swatchtime/swatch-api-demo","last_synced_at":"2026-06-12T15:34:12.218Z","repository":{"id":326390748,"uuid":"1101443024","full_name":"swatchtime/swatch-api-demo","owner":"swatchtime","description":"Javascript demo for Swatch time API usage","archived":false,"fork":false,"pushed_at":"2025-11-29T01:37:37.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-12T15:34:11.222Z","etag":null,"topics":["api","api-demo","api-documentation-tool","clock","demo-app","swatch-internet-time","swatch-time","time"],"latest_commit_sha":null,"homepage":null,"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":"2025-11-21T17:20:09.000Z","updated_at":"2025-11-29T01:37:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/swatchtime/swatch-api-demo","commit_stats":null,"previous_names":["swatchtime/swatch-api-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/swatchtime/swatch-api-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swatchtime%2Fswatch-api-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swatchtime%2Fswatch-api-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swatchtime%2Fswatch-api-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swatchtime%2Fswatch-api-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swatchtime","download_url":"https://codeload.github.com/swatchtime/swatch-api-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swatchtime%2Fswatch-api-demo/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":["api","api-demo","api-documentation-tool","clock","demo-app","swatch-internet-time","swatch-time","time"],"created_at":"2026-06-12T15:34:11.426Z","updated_at":"2026-06-12T15:34:12.213Z","avatar_url":"https://github.com/swatchtime.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swatch Time API Demo\n\nSmall, standalone demo showing how to use the Swatch Internet Time API. This demo is intentionally minimal and uses vanilla JavaScript + Bootstrap so it's easy to copy and adapt.\n\nEndpoint: `https://api.swatchtime.online/api/v1/current`\n\n- The demo shows a set of selectable `fields` that are sent as a comma-separated `fields` query parameter to the API. \n- The rendered `?fields=` text input element is **read-only** and updates as you check/uncheck boxes.\n- Click the green **Fetch API data** button to retrieve data.\n- The \"Sample code to fetch API data\" shows the exact query that is being sent to the API.\n- The sample fetch code demonstrates a robust pattern: it checks `resp.ok`, returns `resp.json()` and includes a `.catch()` handler for errors.\n- The Copy button copies the snippet to the clipboard and shows a short Bootstrap toast confirmation.\n- The demo will display the raw JSON and a parsed, friendly view.\n\n\n## Usage:\n\n- Open `index.html` in a browser. \n\n- Or, run via a simple static web server:\n\n```bash\npython3 -m http.server 8000\n# then load http://localhost:8000/swatch-api-demo in your browser\n```\n\n## Additional Resouces:\n\nhttps://github.com/swatchtime\n\n## License:\n\n[MIT](LICENSE)\n\n\n## API Field Formats (canonical)\n\n - `swatch`: string — beats with two-decimal centibeat precision (e.g. \"123.45\").\n - `whole`: string — floored integer part of beats, zero-padded to 3 digits (e.g. \"005\", \"123\").\n - `rounded`: string — nearest-integer beat, wrapped modulo 1000, zero-padded to 3 digits (e.g. 999.6 -\u003e \"000\").\n - `time24` (BMT): string — 24-hour time derived from Biel Mean Time (e.g. \"16:50:24\").\n - `time12` (BMT): string — 12-hour time derived from Biel Mean Time (e.g. \"04:50:24\").\n - `ampm` (BMT): string — \"AM\" or \"PM\" for the `time12` field.\n - `date` (BMT): string — Biel date in `YYYY-MM-DD` (e.g. \"2025-11-27\").\n\n### Note: Rounding and display (important)\n\nWhen producing the `swatch` field with centibeat precision, implementors must avoid displaying `1000.00`. This can happen if the raw beat (e.g. `999.995`) is rounded to two decimals before wrapping. Use the following safe pattern:\n\n```js\nconst rawBeats = bielSeconds / 86.4;\nlet rounded = Math.round(rawBeats * 100) / 100;\nif (rounded \u003e= 1000) rounded = rounded - 1000;\nconst swatch = rounded.toFixed(2);\n```\n\nThis keeps user-friendly rounding and ensures the beat display stays within `0.00`–`999.99`.\n - `timestamp`: string — ISO-8601 UTC instant (e.g. `2025-11-27T15:50:24.851Z`) — use this for unambiguous UTC comparisons.\n\n#### Implementation notes\n\n- BMT (Biel Mean Time): the API's human-readable date/time fields (`time24`, `time12`, `ampm`, `date`) are presented in BMT — a canonical fixed offset of UTC+1 with no DST.\n- Canonical computation (how `swatch` is derived):\n\t- Compute seconds since UTC midnight including milliseconds.\n\t- Add `3600` seconds (fixed offset for BMT) and wrap modulo `86400`.\n\t- Divide by `86.4` (seconds per beat) to get beats.\n\t- `swatch` is the beats value formatted to two decimals (centibeats).\n\t- `whole` is the floored integer part of beats (zero-padded to 3 digits).\n\t- `rounded` is the nearest integer of beats, then wrapped modulo 1000 and zero-padded to 3 digits.\n- Prefer `timestamp` when you need UTC or when comparing events across timezones.\n- `date`, `time24`, and `time12` are conveniences derived from the same Biel instant used to compute `swatch`, so they match the beat value.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswatchtime%2Fswatch-api-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswatchtime%2Fswatch-api-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswatchtime%2Fswatch-api-demo/lists"}