{"id":15554970,"url":"https://github.com/jakubkrapiec/dateable","last_synced_at":"2026-01-11T04:08:22.050Z","repository":{"id":56827892,"uuid":"263017384","full_name":"jakubkrapiec/dateable","owner":"jakubkrapiec","description":"A Dart package to help you with managing dates easily.","archived":false,"fork":false,"pushed_at":"2023-12-27T12:30:46.000Z","size":55,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T03:01:29.932Z","etag":null,"topics":["dart","dartlang","date","dateformat","datetime","flutter","format"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/dateable","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/jakubkrapiec.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":"2020-05-11T11:01:18.000Z","updated_at":"2023-03-15T19:42:34.000Z","dependencies_parsed_at":"2024-05-15T17:16:32.541Z","dependency_job_id":"0ecd6f75-b275-40f5-b939-249540ba3215","html_url":"https://github.com/jakubkrapiec/dateable","commit_stats":null,"previous_names":["jakubkrapiec/dateable"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakubkrapiec%2Fdateable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakubkrapiec%2Fdateable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakubkrapiec%2Fdateable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakubkrapiec%2Fdateable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jakubkrapiec","download_url":"https://codeload.github.com/jakubkrapiec/dateable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250504085,"owners_count":21441527,"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":["dart","dartlang","date","dateformat","datetime","flutter","format"],"created_at":"2024-10-02T15:05:26.880Z","updated_at":"2026-01-11T04:08:22.024Z","avatar_url":"https://github.com/jakubkrapiec.png","language":"Dart","funding_links":["https://www.buymeacoffee.com/jakubkrapiec"],"categories":[],"sub_categories":[],"readme":"# 📆 Dateable\n\n[![Pub](https://img.shields.io/pub/v/dateable.svg)](https://pub.dartlang.org/packages/dateable)\n\u003ca href=\"https://www.buymeacoffee.com/jakubkrapiec\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/default-blue.png\" alt=\"Buy Me A Coffee\" height=\"20\"  width=\"85\" style=\"height: 20px !important;width: 85px !important;\"\u003e\u003c/a\u003e\n\nA Dart package to help you with managing dates easily. Can be used to store, format, convert, construct, parse and serialise dates. Calendar correctness is guaranteed by the usage of `DateTime`'s system under the hood.\n\n## ⚙️ Import\n\nIn your `.dart` files:\n\n```dart\nimport 'package:dateable/dateable.dart';\n```\n\n## ⚗️ Usage\n\n### 👷 Constructors\n\nVariety of different constructors allows for great flexibility and interoperability with other types.\n\n```dart\nfinal date = Date(31, 12, 2019);\nfinal date = Date.fromDateTime(DateTime(2019, 12, 31, 19, 1)); // Time of day is truncated\nfinal date = Date.parseIso8601('2019-12-31T18:23:48.956871'); // Time of day is truncated\nfinal date = Date.parse('31122019');\nfinal date = Date.today();\nfinal date = Date.yesterday();\nfinal date = Date.tomorrow();\n```\n\nAnd a handy `DateTime` extension:\n\n```dart\nfinal date = DateTime(2019, 12, 31, 13, 26).toDate(); // Time of day is truncated\n```\n\nAll of the above result in the same `date` object!\n\n### 📅 Getters\n\nThere are 4 getters. Simple and easy.\n\n```dart\nfinal date = Date(11, 3, 2002);\nprint(date.day); // Prints 11\nprint(date.month); // Prints 3\nprint(date.year); // Prints 2002\nprint(date.weekday) // Prints 1, since it's a Monday\n```\n\n### ↔️ Conversion methods\n\n`Date` allows for seamless and easy conversions to most commonly used representations!\n\n```dart\nfinal date = Date(11, 3, 2002);\nfinal dateTime = date.toDateTime(); // Time of day is set to zeros\nprint(date.toIso8601()); // Prints 2002-03-11T00:00:00.000\nprint(date.toIso8601(includeTime: false)) // Prints 2002-03-11\nprint(date.toString()); // Prints 11032002\n```\n\n### ✅ Validation\n\nYou can validate your dates easily with the `isValid` static method.\n\nSince the default Date constructor doesn't throw on invalid input, and always tries to silently convert to a valid date instead (just like the `DateTime` constructor), you may want to perform the validation explicitly.\n\n```dart\nprint(Date.isValid(day: 11, month: 3, year: 2002)); // Prints true\nprint(Date.isValid(day: 29, month: 2, year: 2021)); // Prints false\nprint(Date.isValid(day: 40, month: 50, year: -99999)); // Prints true\n```\n\n### 📊 Comparisions\n\nComparisions work just like in your well-known `DateTime` objects!\n\n```dart\nfinal earlier = Date(11, 3, 2002);\nfinal later = Date(21, 9, 2004);\nprint(earlier.isBefore(later)); // True\nprint(later.isAfter(earlier)); // Also true\n```\n\nOn top of this, there are also operators `\u003e` (is after) , `\u003c` (is before), `\u003c=`, `\u003e=` and `==`.\n\nHere comes another handy `DateTime` extension:\n\n```dart\nDateTime(2002, 3, 11, 14, 56, 28).isTheSameDate(Date(11, 3, 2002));\n```\n\nBut if all you want is to check if your `Date` is nearby, here you are.\n\n```dart\nfinal date = Date(11, 3, 2002);\ndate.isToday();\ndate.isYesterday();\ndate.isTomorrow();\n```\n\n### 📰 Formatting\n\nYou can format your `Date`s to `String`s both with top-level constants and with `String` literals:\n\n- `yyyy` - 4 digit year, i.e. 1997\n- `yy` - 2 digit year, i.e. 97\n- `mm` - 2 digit month, i.e. 03\n- `dd` - 2 digit day, i.e. 11\n\nBoth of the below options are correct:\n\n```dart\nDate(11, 3, 2002).format([dd, '-', mm, '-', yyyy])\n```\n\n```dart\nDate(11, 3, 2002).format(['dd', '-', 'mm', 'yyyy'])\n```\n\n### 🔨 Modifiers\n\nLast but not least, there is a set of useful modifiers. Every `Date` object is immutable by default, so each of them creates a new `Date` object.\n\n```dart\ndate.addDays(2) == date + 2 // Always true\ndate.subtractDays(7) == date - 7 // Also always true\n```\n\nYou can also use the idiomatic copyWith function.\n\n```dart\ndate.copyWith(day: 21, month: 9);\n```\n\nSorting an `Iterable` of `Date`s chronologically is even easier:\n\n```dart\n[Date(21, 9, 2004), Date(24, 12, 2006), Date(11, 3, 2002)].sort((a, b) =\u003e a.compareTo(b));\n```\n\nNow the list is `[Date(11, 3, 2002), Date(21, 9, 2004), Date(24, 12, 2006)]`.\n\n## 🐛 Contributing / bug reporting\n\nContributions and bug reports are welcome! Feel free to [open an issue](https://github.com/SugaR256/dateable/issues) or [create a pull request](https://github.com/SugaR256/dateable/pulls).\n\n## 📖 License\n\nThis package is distributed under [MIT license](https://github.com/SugaR256/dateable/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakubkrapiec%2Fdateable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakubkrapiec%2Fdateable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakubkrapiec%2Fdateable/lists"}