{"id":13622597,"url":"https://github.com/ungoldman/format-duration","last_synced_at":"2025-04-09T19:19:25.069Z","repository":{"id":41909561,"uuid":"66689921","full_name":"ungoldman/format-duration","owner":"ungoldman","description":"⏱ Convert milliseconds to a standard duration string.","archived":false,"fork":false,"pushed_at":"2024-08-17T00:21:46.000Z","size":89,"stargazers_count":58,"open_issues_count":0,"forks_count":14,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T19:19:18.866Z","etag":null,"topics":["format","node","time"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ungoldman.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-08-27T01:47:12.000Z","updated_at":"2025-01-15T01:14:01.000Z","dependencies_parsed_at":"2023-02-10T11:32:26.811Z","dependency_job_id":"92f26399-db95-49f6-90ef-8ec8f31734eb","html_url":"https://github.com/ungoldman/format-duration","commit_stats":{"total_commits":58,"total_committers":10,"mean_commits":5.8,"dds":"0.43103448275862066","last_synced_commit":"15dcad129b20ff1854d1682c70aaded73730a194"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ungoldman%2Fformat-duration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ungoldman%2Fformat-duration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ungoldman%2Fformat-duration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ungoldman%2Fformat-duration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ungoldman","download_url":"https://codeload.github.com/ungoldman/format-duration/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248094991,"owners_count":21046770,"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":["format","node","time"],"created_at":"2024-08-01T21:01:21.478Z","updated_at":"2025-04-09T19:19:25.039Z","avatar_url":"https://github.com/ungoldman.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"./stopwatch.png\" alt=\"stopwatch\" width=\"200\"\u003e\n\n# format-duration\n\nConvert a number in milliseconds to a standard duration string.\n\n[![npm][npm-image]][npm-url]\n[![build][build-image]][build-url]\n[![downloads][downloads-image]][npm-url]\n\n[npm-image]: https://img.shields.io/npm/v/format-duration.svg\n[npm-url]: https://www.npmjs.com/package/format-duration\n[build-image]: https://github.com/ungoldman/format-duration/actions/workflows/tests.yml/badge.svg\n[build-url]: https://github.com/ungoldman/format-duration/actions/workflows/tests.yml\n[downloads-image]: https://img.shields.io/npm/dm/format-duration.svg\n\n\u003c/div\u003e\n\n## Install\n\n```\nnpm install format-duration\n```\n\n## Usage\n\n```js\nconst format = require('format-duration')\n\n// anything under a second is rounded down to zero\nformat(999) // '0:00'\n\n// 1000 milliseconds is a second\nformat(1000) // '0:01'\n\n// 1999 rounds down to 0:01\nformat(1000 * 2 - 1) // '0:01'\n\n// 60 seconds is a minute\nformat(1000 * 60) // '1:00'\n\n// 59 seconds looks like this\nformat(1000 * 60 - 1) // '0:59'\n\n// 60 minutes is an hour\nformat(1000 * 60 * 60) // '1:00:00'\n\n// 59 minutes and 59 seconds looks like this\nformat(1000 * 60 * 60 - 1) // '59:59'\n\n// 24 hours is a day\nformat(1000 * 60 * 60 * 24) // '1:00:00:00'\n\n// 23 hours, 59 minutes, and 59 seconds looks like this\nformat(1000 * 60 * 60 * 24 - 1) // '23:59:59'\n\n// 365 days looks like this (not bothering with years)\nformat(1000 * 60 * 60 * 24 * 365) // '365:00:00:00'\n\n// anything under a second is rounded down to zero\nformat(-999) // '0:00'\n\n// 1000 milliseconds is a second\nformat(-1000) // '-0:01'\n\n// 365 days looks like this (not bothering with years)\nformat(-1000 * 60 * 60 * 24 * 365) // '-365:00:00:00'\n\n// with `leading` option, formatting looks like this\nformat(1000 * 60, { leading: true }) // '01:00'\nformat(1000 * 60 - 1, { leading: true }) // '00:59'\nformat(1000 * 60 * 60, { leading: true }) // '01:00:00'\n\n// with `ms` option, formatting looks like this\nformat(999, { ms: true }) // '0:00.999'\nformat(1000 * 60, { ms: true }) // '1:00.000'\nformat(1000 * 60 * 60 * 24 - 1, { ms: true }) // '23:59:59.999'\n```\n\n## Contributing\n\nContributions welcome! Please read the [contributing guidelines](CONTRIBUTING.md) first.\n\n## License\n\n[ISC](LICENSE.md)\n\nStopwatch image is from [emojidex](https://emojidex.com/emoji/stopwatch).\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fungoldman%2Fformat-duration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fungoldman%2Fformat-duration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fungoldman%2Fformat-duration/lists"}