{"id":19009126,"url":"https://github.com/gamtiq/duratiform","last_synced_at":"2025-06-13T01:06:24.524Z","repository":{"id":12701982,"uuid":"15374425","full_name":"gamtiq/duratiform","owner":"gamtiq","description":"Utility to separate into parts and to format time duration in milliseconds","archived":false,"fork":false,"pushed_at":"2020-05-04T13:31:14.000Z","size":1764,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-22T23:23:22.836Z","etag":null,"topics":["decompose","divide","duration","format","interval","millisecond","milliseconds","ms","parse","part","partition","period","separate","span","string","stringify","time"],"latest_commit_sha":null,"homepage":"https://gamtiq.github.io/duratiform/","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/gamtiq.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-22T11:29:57.000Z","updated_at":"2024-01-03T12:22:03.000Z","dependencies_parsed_at":"2022-08-30T14:51:36.469Z","dependency_job_id":null,"html_url":"https://github.com/gamtiq/duratiform","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/gamtiq/duratiform","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamtiq%2Fduratiform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamtiq%2Fduratiform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamtiq%2Fduratiform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamtiq%2Fduratiform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gamtiq","download_url":"https://codeload.github.com/gamtiq/duratiform/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamtiq%2Fduratiform/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259559690,"owners_count":22876499,"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":["decompose","divide","duration","format","interval","millisecond","milliseconds","ms","parse","part","partition","period","separate","span","string","stringify","time"],"created_at":"2024-11-08T19:06:43.004Z","updated_at":"2025-06-13T01:06:24.483Z","avatar_url":"https://github.com/gamtiq.png","language":"JavaScript","readme":"# duratiform\n\nUtility to separate into parts and to format time duration in milliseconds.\n\n```js\nduratiform.divide(123456789000, 4);   // { day: 1428, hour: 21, minute: 33, second: 9 }\nduratiform.format(456789, '(h:h:)(m:mm:)(s:ss)');   // 07:36\n```\n\n[See additional examples below.](#examples)\n\n[![NPM version](https://badge.fury.io/js/duratiform.png)](http://badge.fury.io/js/duratiform)\n[![Build Status](https://travis-ci.org/gamtiq/duratiform.png)](https://travis-ci.org/gamtiq/duratiform)\n\n## Installation\n\n### Node\n\n    npm install duratiform\n\n### [Bower](https://bower.io)\n\n    bower install duratiform\n\n### AMD, \u0026lt;script\u0026gt;\n\nUse `dist/duratiform.js` or `dist/duratiform.min.js` (minified version).\n\n## Usage\n\n### Node\n\n```js\nvar duratiform = require('duratiform');\n```\n\n### AMD\n\n```js\ndefine(['path/to/dist/duratiform.js'], function(duratiform) {\n    ...\n});\n```\n\n### Bower, \u0026lt;script\u0026gt;\n\n```html\n\u003c!-- Use bower_components/duratiform/dist/duratiform.js if the library was installed by Bower --\u003e\n\u003cscript type=\"text/javascript\" src=\"path/to/dist/duratiform.js\"\u003e\u003c/script\u003e\n\u003cscript type=\"text/javascript\"\u003e\n    // duratiform is available via duratiform field of window object\n    ...\n\u003c/script\u003e\n```\n\n### Examples \u003ca name=\"examples\"\u003e\u003c/a\u003e\n\n```js\nvar nDuration = 123456789000;\nconsole.log('5 duration parts: ', duratiform.divide(nDuration, 5));   // { week: 204, day: 0, hour: 21, minute: 33, second: 9 }\nconsole.log(nDuration, ' - ', duratiform.format(nDuration, 'w [weeks] d [days] h [hours] m [minutes] s [seconds]'));   // 204 weeks 0 days 21 hours 33 minutes 9 seconds\nconsole.log('4 duration parts: ', duratiform.divide(nDuration, 4));   // { day: 1428, hour: 21, minute: 33, second: 9 }\nconsole.log(nDuration, ' - ', duratiform.format(nDuration, 'd [days] h [hours] m [minutes] s [seconds]'));   // 1428 days 21 hours 33 minutes 9 seconds\n\nconsole.log('120184000, 4 parts - ', duratiform.divide(120184000, 4));   // { day: 1, hour: 9, minute: 23, second: 4 }\nconsole.log('120184000, 4 parts and strings - ', duratiform.divide(120184000, 4, true));   // { day: 1, day2: \"01\", hour: 9, hour2: \"09\", minute: 23, minute2: \"23\", second: 4, second2: \"04\" }\nconsole.log('120184000, 3 parts - ', duratiform.divide(120184000, 3));   // { hour: 33, minute: 23, second: 4 }\n\nconsole.log('4567890 - ', duratiform.format(4567890, '(h:h:)(m:mm:)(s:ss)'));   // 1:16:07\nconsole.log('456789 - ', duratiform.format(456789, '(h:h:)(m:mm:)(s:ss)'));   // 07:36\nconsole.log('456789 - ', duratiform.format(456789, '(h:h:(m:mm:)(s:ss))'));   // empty string\n\nconsole.log('4567890 - ', duratiform.format(4567890, 'Duration:(h: h [hr](m: mm [min](s: ss [sec])))(!h: (m:m [min](s: ss [sec]))(!m:s [sec]))'));   // Duration: 1 hr 16 min 07 sec\nconsole.log('456789 - ', duratiform.format(456789, 'Duration:(h: h [hr](m: mm [min](s: ss [sec])))(!h: (m:m [min](s: ss [sec]))(!m:s [sec]))'));   // Duration: 7 min 36 sec\nconsole.log('6789 - ', duratiform.format(6789, 'Duration:(h: h [hr](m: mm [min](s: ss [sec])))(!h: (m:m [min](s: ss [sec]))(!m:s [sec]))'));   // Duration: 6 sec\n\n```\n\nSee `test/duratiform.js` for additional examples.\n\n## API\n\n### [divide(nDuration: number, [nPartQty: number], [bAddStrings: boolean]): object](https://gamtiq.github.io/duratiform/module-duratiform.html#.divide)\n\nSeparate time duration into parts.\n\n### [format(nDuration: number, [sFormat: string]): string](https://gamtiq.github.io/duratiform/module-duratiform.html#.format)\n\nConvert time duration into string.\n\nSee [`docs`](https://gamtiq.github.io/duratiform/) for details.\n\n## License\n\nMIT\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamtiq%2Fduratiform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgamtiq%2Fduratiform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamtiq%2Fduratiform/lists"}