{"id":24143294,"url":"https://github.com/little-core-labs/npt-timecode","last_synced_at":"2025-07-15T04:36:21.035Z","repository":{"id":57154954,"uuid":"331124131","full_name":"little-core-labs/npt-timecode","owner":"little-core-labs","description":"Atomic classes for working with Normal Play Time (NPT) time codes from RFC 2326.","archived":false,"fork":false,"pushed_at":"2021-01-21T16:42:12.000Z","size":25,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-28T03:06:19.676Z","etag":null,"topics":["2326","normal","npt","play","rfc","time"],"latest_commit_sha":null,"homepage":"","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/little-core-labs.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}},"created_at":"2021-01-19T22:14:42.000Z","updated_at":"2021-01-21T16:42:14.000Z","dependencies_parsed_at":"2022-09-06T20:12:45.213Z","dependency_job_id":null,"html_url":"https://github.com/little-core-labs/npt-timecode","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/little-core-labs/npt-timecode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fnpt-timecode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fnpt-timecode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fnpt-timecode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fnpt-timecode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/little-core-labs","download_url":"https://codeload.github.com/little-core-labs/npt-timecode/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fnpt-timecode/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265402833,"owners_count":23759237,"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":["2326","normal","npt","play","rfc","time"],"created_at":"2025-01-12T05:14:56.668Z","updated_at":"2025-07-15T04:36:21.010Z","avatar_url":"https://github.com/little-core-labs.png","language":"JavaScript","readme":"npt-timecode\n============\n\n\u003e Atomic classes for working with Normal Play Time (NPT) time codes from [RFC 2326](https://www.ietf.org/rfc/rfc2326).\n\n## Status\n\n![](https://github.com/little-core-labs/npt-timecode/workflows/Tests/badge.svg)\n\n## Installation\n\n```sh\n$ npm install npt-timecode\n```\n\n## Usage\n\n```js\nconst { Timecode } = require('npt-timecode')\nconst timecode = Timecode.from('00:00:30.456-00:01:00.789')\nconsole.log(timecode)\n// Timecode (00:00:30.456-00:01:00.789) {\n//   start: Time (00:00:30.456) { value: 30.456 },\n//   stop: Time (00:01:00.789) { value: 60.789 }\n// }\n```\n\n## API\n\n### `Timecode`\n\nA container for Normal Play Time (NPT) timecodes that support ranges.\n\n#### `timecode = Timecode.from(input)`\nCreates a `Timecode` instance from input.\n\n```js\nTimecode.from({ start: 0, stop: 30.5 }) // in seconds\nTimecode.from({ start: 'now' })\nTimecode.from({ start: '00:05:32.5', stop: '00:06:00' })\nTimecode.from('now-')\nTimecode.from('00:05:32.5-00:06:00')\nTimecode.from('00:05:00', '00:06:00')\n```\n\n#### `timecode.start`\n\nA `Time` instance that represents the start value of a timecode range.\nIf a range is not give, then it is the timecode value.\n\n#### `timecode.stop`\n\nA `Time` instance that represents the stop value of a timecode range.\nThis time value may not be set if the timecode is not a range.\n\n#### `timecode.set(start[, stop])`\n\nSet the start and optional stop time values for this range.\n\n```js\ntimecode.set(30, 60) // 00:00:30-00:01:00\n```\n\n#### `timecode.reset()`\n\nReset the timecode state.\n\n### `Time`\n\nA container for a NPT integer time value represented in seconds.\n\n#### `Time.NOW`\n\nA constant to represent \"now\" in a NPT scheme.\n\n### `time = Time.from(input)`\n\nCreates a `Time` instance from input.\n\n```js\nconst time = Time.from(305.5) // 5 minutes, 5 seconds, and half a second\n// or\nconst time = Time.from('5:5.5')\n// or\nconst time = Time.from('00:05:5.5')\n// or\nconst time = Time.from({ minutes: 5, seconds: 5.5 })\n```\n\n### `time = Time.now()`\n\nCreates a \"now\" `Time` instance.\n\n```js\nconst now =  Time.now()\n```\n\n#### `time.value`\n\nThe integer value of the `Time` instance.\n\n#### `time.isNow`\n\n`true` if the time value is the \"now\" constant.\n\n#### `time.isValid`\n\n`true` if the time value is valid. Meaning the time value is a valid\nfinite integer.\n\n#### `time.totalHours`\n\nComputed total number of hours this `Time` instance represents.\n\n#### `time.totalMinutes`\n\nComputed total number of minutes this `Time` instance represents.\n\n#### `time.totalSeconds`\n\nComputed total number of seconds this `Time` instance represents.\n\n#### `time.totalMilliseconds`\n\nComputed total number of milliseconds this `Time` instance represents.\n\n#### `time.hours`\n\nComputed number of hours this `Time` instance represents.\n\n#### `time.minutes`\n\nComputed number of minutes this `Time` instance represents.\n\n#### `time.seconds`\n\nComputed number of seconds this `Time` instance represents.\n\n#### `time.milliseconds`\n\nComputed number of milliseconds this `Time` instance represents.\n\n#### `time.ms`\n\nAn alias for `time.milliseconds`.\n\n#### `time.set(value)`\n\nSet the time value for this instance.\n\n#### `time.reset()`\n\nResets the value of this `Time` instance to `Number.NaN`.\n\n#### `time.toString(format = 'hh:mm:ss')`\n\nConverts this `Time` instance to an optionally formatted string.\n\n```js\ntime.toString('hh:mm::ss') // default format, padded time\ntime.toString('hh') // padded hours\ntime.toString('mm') // padded minutes\ntime.toString('ss') // padded seconds\ntime.toString('H') // total hours, not padded\ntime.toString('M') // total minutes, not padded\ntime.toString('S') // total seconds, not padded\n```\n\n### `ms = parse(string)`\n\nParse a NPT time string into milliseconds. This function does not parse\nrange values.\n\n## License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittle-core-labs%2Fnpt-timecode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flittle-core-labs%2Fnpt-timecode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittle-core-labs%2Fnpt-timecode/lists"}