{"id":21986713,"url":"https://github.com/smt/beat-js","last_synced_at":"2025-08-01T01:18:07.159Z","repository":{"id":245452489,"uuid":"817938289","full_name":"smt/beat-js","owner":"smt","description":"Parsing and formatting .beat time (a.k.a. Swatch Internet Time)","archived":false,"fork":false,"pushed_at":"2024-06-21T14:21:53.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-28T05:25:48.371Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/smt.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}},"created_at":"2024-06-20T18:56:44.000Z","updated_at":"2024-06-21T14:21:56.000Z","dependencies_parsed_at":"2024-06-22T07:07:34.837Z","dependency_job_id":null,"html_url":"https://github.com/smt/beat-js","commit_stats":null,"previous_names":["smt/beat-js"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smt%2Fbeat-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smt%2Fbeat-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smt%2Fbeat-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smt%2Fbeat-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smt","download_url":"https://codeload.github.com/smt/beat-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245045356,"owners_count":20552032,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-29T18:20:35.648Z","updated_at":"2025-03-23T02:21:13.679Z","avatar_url":"https://github.com/smt.png","language":"TypeScript","readme":"# beat-js\n\nUtilities to support [.beat time (a.k.a. Swatch Internet Time)](https://en.wikipedia.org/wiki/Swatch_Internet_Time).\n\n## What is a .beat?\n\nThe Wikipedia link above explains it the best, but to summarize...\n\n**.beat time** is a form of decimal time, where each day is divided into 1,000 parts called _.beats_. Each .beat lasts for 86.4 seconds in standard time.\n\n.beat time is always relative to midnight, Central European Time (UTC+1). There are no timezones, and no DST rules. At 42 .beats past midnight CET, the .beat time is represented this way: **@042**.\n\n## tl;dr\n\nThis tiny library provides some trivial utilities to format a Date as .beat time, or find the start and end times for a .beat time.\n\nThe main use case is to simply output the current time formatted as .beat time, like so:\n\n```ts\nimport { beat } from \"@smt/beat\";\n\nbeat();\n// =\u003e \"@123\"\n```\n\n## Installation\n\n**@smt/beat** is a [JSR](https://jsr.io/docs/introduction) package. As such, you may use the following methods to install it in your JavaScript or TypeScript project.\n\n### Deno\n\nWith Deno, you may optionally use this package without an install step like so:\n\n```ts\nimport { beat } from \"jsr:@smt/beat\";\n```\n\nOtherwise, you can install it using the following command:\n\n```sh\ndeno add @smt/beat\n```\n\nThe install step will add an import map entry to the `deno.json` file, looking something like this:\n\n```json\n{\n  \"imports\": {\n    \"@smt/beat\": \"jsr:@smt/beat@^0.0.1\"\n  }\n}\n```\n\n### npm and npm-compatible package managers\n\nWith npm, you may install this package using one of the following commands, depending on the package manager you are using:\n\n```sh\nnpx jsr add @smt/beat\nyarn dlx jsr add @smt/beat\npnpm dlx jsr add @smt/beat\nbunx jsr add @smt/beat\n```\n\nThe install step will add a dependency entry to the `package.json` file, looking something like this:\n\n```json\n{\n  \"dependencies\": {\n    \"@smt/beat\": \"npm:@jsr/smt__beat@^0.0.1\"\n  }\n}\n```\n\nThis will also modify the `.npmrc` file to enable the custom `@jsr` scope, like so:\n\n```\n@jsr:registry=https://npm.jsr.io\n```\n\nPlease ensure that you check the modified `.npmrc` file into source control after installation.\n\n## Usage\n\n### beat()\n\nReturns a .beat time as a string.\n\nThe first argument may be a string in ISO-8601 format or a Date object. If no value is provided, or if a valid date cannot be parsed from the provided value, the function will default to using the current time.\n\n```ts\nimport { beat } from \"@smt/beat\";\n\n// Get the .beat for the current time (default)\nbeat();\n// =\u003e \"@789\"\n\n// Get the .beat from an ISO-8601 datetime string\nbeat(\"2024-06-21T00:00:00.000Z\");\n// =\u003e \"@041\"\n\n// Get the .beat from a Date object\nbeat(new Date(\"2024-06-21T00:00:00.000Z\"));\n// =\u003e \"@041\"\n```\n\n### isBeat()\n\nA convenience utility to check if the given value is a .beat time, based on the following regex: `/^@(\\d{3})$/`.\n\n```ts\nimport { isBeat } from \"@smt/beat\";\n\nisBeat(\"@123\");\n// =\u003e true\n\nisBeat(123);\n// =\u003e false\n\nisBeat(\"123\");\n// =\u003e false\n\nisBeat(\"LOL\");\n// =\u003e false\n\nisBeat(null);\n// =\u003e false\n```\n\n### toInterval()\n\nReturns an Interval object containing the start Date and end Date of the given .beat time.\n\nBy default, it assumes the interval should be future-dated relative to the current time, but you can override this by using the `from` (future-date starting from the provided Date) or `until` (past-date based on the provided Date) options.\n\n```ts\nimport { toInterval } from \"@smt/beat\";\n\n// Get the start and end of the .beat (future-dated relative to the current time)\ntoInterval(\"041\");\n// =\u003e { start: 2024-06-20T23:59:02.400Z, end: 2024-06-21T00:00:28.800Z }\n\n// Get the start and end of the .beat (future-dated relative to the provided time)\ntoInterval(\"041\", { from: new Date(\"2024-06-21T00:00:00.000Z\") });\n// =\u003e { start: 2024-06-21T23:59:02.400Z, end: 2024-06-22T00:00:28.800Z }\n\n// Get the start and end of the .beat (past-dated relative to the provided time)\ntoInterval(\"041\", { until: new Date(\"2024-06-21T00:00:00.000Z\") });\n// =\u003e { start: 2024-06-19T23:59:02.400Z, end: 2024-06-20T00:00:28.800Z }\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmt%2Fbeat-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmt%2Fbeat-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmt%2Fbeat-js/lists"}