{"id":15498052,"url":"https://github.com/x-slayer/humanize_duration","last_synced_at":"2025-04-22T22:44:50.825Z","repository":{"id":57699168,"uuid":"500825134","full_name":"X-SLAYER/Humanize_duration","owner":"X-SLAYER","description":"Humanize a duration to a readable format | 361000 becomes \"6 minutes, 1 second\"","archived":false,"fork":false,"pushed_at":"2024-02-08T19:49:00.000Z","size":234,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-18T10:41:30.024Z","etag":null,"topics":["duration","flutter","flutter-package","humanize-duration","time","x-slayer"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/humanize_duration","language":"Dart","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/X-SLAYER.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-07T12:10:55.000Z","updated_at":"2024-06-12T08:13:06.000Z","dependencies_parsed_at":"2024-10-02T08:41:52.430Z","dependency_job_id":"0d8655d2-fbaf-4034-9b61-9ea1cd1b0cfb","html_url":"https://github.com/X-SLAYER/Humanize_duration","commit_stats":{"total_commits":16,"total_committers":1,"mean_commits":16.0,"dds":0.0,"last_synced_commit":"186b0ce532f7ac25bf0f54bf56488f96d9a983d1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X-SLAYER%2FHumanize_duration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X-SLAYER%2FHumanize_duration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X-SLAYER%2FHumanize_duration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X-SLAYER%2FHumanize_duration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/X-SLAYER","download_url":"https://codeload.github.com/X-SLAYER/Humanize_duration/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250337847,"owners_count":21414099,"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":["duration","flutter","flutter-package","humanize-duration","time","x-slayer"],"created_at":"2024-10-02T08:41:45.740Z","updated_at":"2025-04-22T22:44:50.803Z","avatar_url":"https://github.com/X-SLAYER.png","language":"Dart","readme":"# Humanize Duration\n\nHumanize a duration to a readable format.\ninspired from [humanizeDuration.js](https://github.com/EvanHahn/HumanizeDuration.js)\n\n### Installation and usage\n\nAdd package to your pubspec:\n\n```yaml\ndependencies:\n  humanize_duration: any # or the latest version on Pub\n```\n\n## Usage\n\nBy default, Humanize Duration will humanize down to the millisecond. It will humanize in English by default.\n\n```dart\nhumanizeDuration(const Duration(milliseconds: 3000)); // '3 seconds'\nhumanizeDuration(const Duration(milliseconds: 97320000)); // '1 day, 3 hours, 2 minutes'\n```\n\n# Options and languages\n\n### languages\n\nSupported languages: [Arabic, French, English, Spanish ...]\nFor a list of supported languages, you can use the `getSupportedLanguages`\n\n```dart\n\ngetSupportedLanguages(); // [ar, en, fr, es, jp, gr, du, fa, ge, it, ko, pt, ru, tr, zh_cn, zh_tw]\n\nhumanizeDuration(\n  const Duration(milliseconds: 97320000),\n  language: const ArLanguage(),\n);\n//  ١ يوم , ٣ ساعات\n\n// OR get language by alpha\nhumanizeDuration(\n  const Duration(milliseconds: 97320000),\n  language: getLanguageByLocale('ar'),\n);\n\n```\n\n### Add a custom language\n\nFirstly you need to implement [HumanizeLanguage](https://github.com/X-SLAYER/Humanize_duration/blob/main/lib/src/humanize_language.dart) class.\n\n```dart\nimport 'package:humanize_duration/humanize_duration.dart';\n\nclass EuLanguage implements HumanizeLanguage {\n const EuLanguage();\n\n @override\n String name() =\u003e 'eu';\n\n @override\n String day(int value) =\u003e 'egun';\n\n @override\n String hour(int value) =\u003e 'ordu';\n\n @override\n String millisecond(int value) =\u003e 'milisegundo';\n\n @override\n String minute(int value) =\u003e 'minutu';\n\n @override\n String month(int value) =\u003e 'hilabete';\n\n @override\n String second(int value) =\u003e 'segundo';\n\n @override\n String week(int value) =\u003e 'aste';\n\n @override\n String year(int value) =\u003e 'hilabete';\n}\n\n\n```\n\n### delimiter\n\nString to display between the previous unit and the next value.\n\n```dart\nhumanizeDuration(\n    const Duration(milliseconds: 97320000),\n    options: const HumanizeOptions(delimiter: ' -- '),\n  ); // 1 day -- 3 hours -- 2 minutes\n\nhumanizeDuration(\n  const Duration(milliseconds: 22140000),\n  options: const HumanizeOptions(delimiter: ' and '),\n); // 6 hours and 9 minutes\n\n```\n\n### spacer\n\nString to display between each value and unit.\n\n```dart\nhumanizeDuration(\n  const Duration(milliseconds: 22140000),\n  options: const HumanizeOptions(spacer: ' whole '),\n); // 6 whole hours, 9 whole minutes\n\n```\n\n### units\n\nIt can be one, or a combination of any, of the following.\n`Units.year`, `Units.month`, `Units.week`, `Units.day`, `Units.hour`, `Units.minute`, `Units.second`, `Units.millisecond`.\n\n```dart\nhumanizeDuration(\n  const Duration(milliseconds: 3600000),\n  options: const HumanizeOptions(units: [Units.hour]),\n); // 1 hour\n\nhumanizeDuration(\n  const Duration(milliseconds: 3600000),\n  options: const HumanizeOptions(units: [Units.minute]),\n); // 60 minutes\n\nhumanizeDuration(\n  const Duration(milliseconds: 3600000),\n  options: const HumanizeOptions(units: [Units.day, Units.hour]),\n); // 1 hour\n\n```\n\n### conjunction\n\nString to include before the final unit.\nYou can also set `lastPrefixComma` to `false` to eliminate the final comma.\n\n```dart\nhumanizeDuration(\n  const Duration(milliseconds: 22140000),\n  options: const HumanizeOptions(conjunction: ' and '),\n); // 6 hours and 9 minutes\n\nhumanizeDuration(\n  const Duration(milliseconds: 22141000),\n  options: const HumanizeOptions(conjunction: ' and '),\n); // 6 hours, 9 minutes and 1 second\n\n humanizeDuration(\n  const Duration(milliseconds: 22141000),\n  options: const HumanizeOptions(\n    conjunction: ' and ',\n    lastPrefixComma: true,\n  ),\n); // 6 hours, 9 minutes, and 1 second\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx-slayer%2Fhumanize_duration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fx-slayer%2Fhumanize_duration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx-slayer%2Fhumanize_duration/lists"}