Registry / testing / timeprettify

timeprettify

JSON →
library0.0.7jsnpmunverified

Lightweight duration formatter with multi-locale support. Current stable version is 0.0.7. It provides a simple `format` function to convert seconds into human-readable strings like '1 hour 1 minute', supporting four locales (English, Turkish, Turkmen, Russian) and three styles (long, short, narrow). Releases are infrequent. Key differentiators: no dependencies, TypeScript-first, small bundle size, and plural rule support for Russian. A `createFormatter` factory enables reusable preset configurations.

npm install timeprettify
INSTALL
IMPORT
SIG · TIMEPRETTIFY
T
timeprettify
testingjavascriptv0.0.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

format
import { format } from 'timeprettify'
const format = require('timeprettify').format
Package exports ES modules primarily; CommonJS require may not work in all bundlers.
createFormatter
import { createFormatter } from 'timeprettify'
import createFormatter from 'timeprettify'
createFormatter is a named export, not a default export.
FormatOptions
import type { FormatOptions } from 'timeprettify'
No mistake commonly associated.
Type-only import is recommended for TypeScript users to avoid runtime inclusion.
Locale
import type { Locale } from 'timeprettify'
No mistake commonly associated.
Type-only import for TypeScript users; Locale is a union type of supported locales.
Style
import type { Style } from 'timeprettify'
No mistake commonly associated.
Type-only import for TypeScript users; Style is a union type of 'long' | 'short' | 'narrow'.

Demonstrates basic usage of format and createFormatter with options.

import { format, createFormatter } from 'timeprettify'; console.log(format(3661)); // '1 hour 1 minute' console.log(format(3661, { locale: 'ru', style: 'short' })); // '1ч 1мин' const formatTr = createFormatter({ locale: 'tr' }); console.log(formatTr(120)); // '2 dakika' console.log(formatTr(120, { style: 'short' })); // '2dk'
Debug
Known issues
deprecatedOption `unit` (singular) was deprecated in v0.0.5. Use `units` (plural) instead.
fix
Replace `unit` with `units` in options object.
affects: >=0.0.5 <0.0.6
breakingIn v0.0.4, the default locale changed from `'tr'` to `'en'`. Existing code relying on Turkish output without specifying locale will now output English.
fix
Explicitly pass `{ locale: 'tr' }` to all format calls if Turkish output is required.
affects: >=0.0.4
breakingIn v0.0.6, the `format` function no longer accepts a string for seconds; it now requires a number. Passing a string will throw a TypeError.
fix
Convert string inputs to numbers before calling `format`.
affects: >=0.0.6
deprecatedLocale `'fr'` was removed in v0.0.7. Using it will fall back to `'en'`.
fix
Use one of the supported locales: 'en', 'tr', 'ru', 'tm'.
affects: >=0.0.7
gotchaThe maximum value for seconds is Number.MAX_SAFE_INTEGER. Large numbers may produce unexpected results due to floating-point precision.
fix
Limit input to Number.MAX_SAFE_INTEGER or use BigInt if needed (not supported currently).
affects: all
gotchaUsing `style: 'narrow'` with certain locales (e.g., Russian) may produce non-standard abbreviations that are not universally understood.
fix
Consider using 'short' style for broader readability.
affects: all
Errors
Common errors & fixes
TypeError: format is not a function
Importing the package using default import instead of named import.
fix
Use `import { format } from 'timeprettify'` instead of `import format from 'timeprettify'`.
Cannot find module 'timeprettify' or its corresponding type declarations
Package may not be installed or TypeScript cannot resolve the types.
fix
Run `npm install timeprettify` and ensure `esModuleInterop` is enabled in tsconfig.json.
Uncaught TypeError: seconds should be a number
Passing a string to the `format` function.
fix
Convert the argument to a number: `format(Number(seconds))`.
Invalid locale: 'fr'
Locale 'fr' is not supported; available locales are 'en', 'tr', 'ru', 'tm'.
fix
Use one of the supported locales or remove the locale option to default to 'en'.
Upgrade
Version history
0.0.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources