The `hh-mm-ss` package provides a lightweight and focused utility for converting time representations between numerical values (seconds or milliseconds) and formatted strings like `hh:mm:ss`. Currently stable at version `1.2.0`, the library appears to have a conservative release cadence, with updates primarily focused on adding new format support and convenience methods incrementally, rather than frequent major changes. Its core differentiator lies in its specialization, offering a simpler alternative to larger, more comprehensive date-time libraries by focusing solely on common `hh:mm:ss` patterns and handling ambiguities with optional format parameters. It supports various time string patterns, including `mm:ss`, `hh:mm`, `hh:mm:ss`, and their millisecond-inclusive variants like `mm:ss.sss`, with a mechanism to automatically extend output formats to preserve precision when milliseconds are present.
npm install hh-mm-ssVerified import paths — ran on the pinned version, not inferred.
Demonstrates converting various time string formats to seconds and milliseconds, and vice-versa, using explicit format parameters to avoid ambiguity.
Always explicitly provide the `format` parameter (e.g., `TimeFormat.toS('02:00', 'hh:mm')`) to prevent ambiguous interpretations and ensure correct conversion.If a strictly limited output format is necessary (e.g., exactly `mm:ss`), round or truncate the input milliseconds (`ms`) before passing them to `fromMs`. Alternatively, handle the extended output format in your downstream logic.
In ES Module projects, use the ESM import syntax: `import TimeFormat from 'hh-mm-ss';`. Ensure your build tools are configured to correctly transpile or resolve CommonJS modules for browser or other specialized environments.
Change the import statement to use ESM syntax: `import TimeFormat from 'hh-mm-ss';`. If using TypeScript, ensure `tsconfig.json`'s `moduleResolution` is set appropriately (e.g., `node16` or `nodenext`).
Ensure `TimeFormat` is imported as a default export: `import TimeFormat from 'hh-mm-ss';` for ESM, or `const TimeFormat = require('hh-mm-ss');` for CommonJS. Then access methods via the imported object, e.g., `TimeFormat.toS(...)`.Explicitly specify the input format when calling the conversion function: `TimeFormat.toS('02:00', 'hh:mm')`. Similarly, for `fromS` or `fromMs`, specify the desired output format.No dependency data recorded yet.