{"id":15293118,"url":"https://github.com/litlifesoftware/lit_relative_date_time","last_synced_at":"2025-10-23T06:32:16.157Z","repository":{"id":61973932,"uuid":"350817059","full_name":"litlifesoftware/lit_relative_date_time","owner":"litlifesoftware","description":"A Flutter package to generate relative dates to show differences in time in localized and human-readable format.","archived":true,"fork":false,"pushed_at":"2021-11-20T17:08:55.000Z","size":360,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-01T15:40:33.699Z","etag":null,"topics":["android","dart","date","datetime","flutter","i18n","ios","localization"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/lit_relative_date_time","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/litlifesoftware.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}},"created_at":"2021-03-23T18:30:05.000Z","updated_at":"2024-03-23T13:43:06.000Z","dependencies_parsed_at":"2022-10-24T13:30:51.419Z","dependency_job_id":null,"html_url":"https://github.com/litlifesoftware/lit_relative_date_time","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litlifesoftware%2Flit_relative_date_time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litlifesoftware%2Flit_relative_date_time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litlifesoftware%2Flit_relative_date_time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litlifesoftware%2Flit_relative_date_time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/litlifesoftware","download_url":"https://codeload.github.com/litlifesoftware/lit_relative_date_time/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235599560,"owners_count":19016190,"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":["android","dart","date","datetime","flutter","i18n","ios","localization"],"created_at":"2024-09-30T16:39:52.530Z","updated_at":"2025-10-07T06:30:27.328Z","avatar_url":"https://github.com/litlifesoftware.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LitRelativeDateTime\n\n\u003e [![leitmotif][leitmotif_badge_pub]][leitmotif] [![pub points][leitmotif_badge_pub_points]][leitmotif_pub_points]\n\nby [LitLifeSoftware](https://github.com/litlifesoftware)\n\n## What is LitRelativeDateTime?\n\nLitRelativeDateTime is a Flutter package to generate relative dates to show differences in time. Theses dates are formatted in a localized and human-readable format.\n\n## Screenshots\n\n| English Locale     | German Locale      |\n| ------------------ | ------------------ |\n| ![1][screenshot_1] | ![2][screenshot_2] |\n\n## How it works\n\nThe `RelativeDateTime` takes two `DateTime` objects and calculates the difference in time of both dates. This relative time difference is\nthen used for localizing and formatting the expression in human-readable format.\n\n## How to use\n\nFirst the delegates and supported locales should be declared on your `MaterialApp` to enable localization for your app:\n\n```dart\nlocalizationsDelegates: [\n  GlobalMaterialLocalizations.delegate,\n  GlobalWidgetsLocalizations.delegate,\n  GlobalCupertinoLocalizations.delegate,\n],\n// Set the supported locales according to the localizations you have\n// implmented on your application.\nsupportedLocales: [\n  const Locale('en'), // English, no country code\n  const Locale('de'), // German, no country code\n  const Locale('ru'), // Russian, no country code\n],\n```\n\nTo display localized and formatted dates relative to another date in human-readable format, first a `RelativeDateTime` object should be created:\n\n```dart\n    RelativeDateTime _relativeDateTime =\n        RelativeDateTime(dateTime: DateTime.now(), other: _otherDateTime);\n```\n\nNext the `RelativeDateFormat` object can be initialized. It will enable formatting the previously\ncreated `RelativeDateTime`:\n\n```dart\nRelativeDateFormat _relativeDateFormatter = RelativeDateFormat(\n    Localizations.localeOf(context),\n);\n```\n\nIf you want to provide your own Localizations, you can do so by passing the optional `localizations`\nargument, which contains a list of `RelativeDateLocalization` objects:\n\n```dart\nRelativeDateLocalization(\n  languageCode: 'en',\n  timeUnitsSingular: [\n    'second',\n    'minute',\n    'hour',\n    'day',\n    'week',\n    'month',\n    'year',\n  ],\n  timeUnitsPlural: [\n    'seconds',\n    'minutes',\n    'hours',\n    'days',\n    'weeks',\n    'months',\n    'years',\n  ],\n  prepositionPast: 'ago',\n  prepositionFuture: 'in',\n  atTheMoment: 'now',\n  formatOrderPast: [\n    FormatComponent.value,\n    FormatComponent.unit,\n    FormatComponent.preposition\n  ],\n  formatOrderFuture: [\n    FormatComponent.preposition,\n    FormatComponent.value,\n    FormatComponent.unit,\n  ],\n);\n```\n\nNow the `RelativeDateFormat`'s `format()` method can be called, which takes the `RelativeDateTime` as\nan argument in order to format the `RelativeDateTime` to display the string on e.g. a `Text` widget:\n\n```dart\nText(relativeDateFormatter.format(relativeDateTime))\n```\n\nThere is an `AnimatedBuilder` implementation (`AnimatedRelativeDateTimeBuilder`) available to display `RelativeDateTime` values relative\nto the current timestamp. The animation renders every second to allow updating the builder\nevery past second.\n\n```dart\nAnimatedRelativeDateTimeBuilder(\n    date: _lastPressed!,\n    builder: (relDateTime, formatted) {\n      return Text(\n        formatted,\n      );\n    },\n  );\n```\n\nThe Example app can provide further details on implementing relative dates.\n\n## Getting Started with Flutter\n\nFor help getting started with Flutter, view our\n[online documentation](https://flutter.dev/docs), which offers tutorials,\nsamples, guidance on mobile development, and a full API reference.\n\n## Example\n\nThe `example` folder contains an example app demonstrating how LitRelativeDateTime could implemented.\n\n## License\n\nThe source code of this repository is distributed under the\n**BSD 3-Clause** license as specified in the `LICENSE` file.\n\n[screenshot_1]: assets/img/Screenshot_1.png\n[screenshot_2]: assets/img/Screenshot_2.png\n[leitmotif]: https://pub.dev/packages/lit_relative_date_time\n[leitmotif_pub_points]: https://pub.dev/packages/lit_relative_date_time/score\n[leitmotif_badge_pub]: https://img.shields.io/pub/v/lit_relative_date_time.svg\n[leitmotif_badge_pub_points]: https://badges.bar/lit_relative_date_time/pub%20points\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flitlifesoftware%2Flit_relative_date_time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flitlifesoftware%2Flit_relative_date_time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flitlifesoftware%2Flit_relative_date_time/lists"}