{"id":14158261,"url":"https://github.com/vercel/little-date","last_synced_at":"2025-05-14T14:07:27.016Z","repository":{"id":251999567,"uuid":"707325765","full_name":"vercel/little-date","owner":"vercel","description":"A friendly formatter to make date ranges small \u0026 sweet","archived":false,"fork":false,"pushed_at":"2024-08-20T16:20:51.000Z","size":569,"stargazers_count":1906,"open_issues_count":8,"forks_count":16,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-11T07:26:51.833Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/vercel.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2023-10-19T17:02:44.000Z","updated_at":"2025-05-10T12:14:20.000Z","dependencies_parsed_at":"2024-08-07T03:26:30.338Z","dependency_job_id":"b6f7b0cf-b524-4e62-a66f-4038fff416ad","html_url":"https://github.com/vercel/little-date","commit_stats":{"total_commits":54,"total_committers":3,"mean_commits":18.0,"dds":0.03703703703703709,"last_synced_commit":"700e291eeed52bd02a6d5e31faca6351d4820e7f"},"previous_names":["vercel/little-date","timolins/little-date"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel%2Flittle-date","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel%2Flittle-date/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel%2Flittle-date/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel%2Flittle-date/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vercel","download_url":"https://codeload.github.com/vercel/little-date/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253534084,"owners_count":21923515,"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":[],"created_at":"2024-08-17T09:01:58.229Z","updated_at":"2025-05-14T14:07:26.978Z","avatar_url":"https://github.com/vercel.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003cimg alt=\"little-date banner\" src=\"https://github.com/vercel/little-date/raw/main/.github/banner.png\"/\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"https://badgen.net/npm/v/little-date?\" alt=\"NPM Version\" /\u003e\n    \u003cimg src=\"https://github.com/vercel/little-date/workflows/CI/badge.svg\" alt=\"Build Status\" /\u003e\n\u003c/a\u003e\n\u003c/div\u003e\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\u003cstrong\u003eSmall \u0026 sweet date-range formatting\u003c/strong\u003e\u003c/div\u003e\n\u003cdiv align=\"center\"\u003eAn opinionated library that makes date-ranges short and readable.\u003c/div\u003e\n\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003csub\u003ePrepared by \u003ca href=\"https://x.com/timolins\"\u003eTimo Lins\u003c/a\u003e 👨‍🍳 during a \u003ca href=\"https://vercel.com/?ref=little-date\"\u003e▲ Vercel\u003c/a\u003e Hackathon\u003c/sub\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\n## Introduction\n\nWhen displaying date-ranges in UI, they are often too long, repetitive, and hard to read. `little-date` solves this problem by making date ranges **short**, **readable**, and **easy to understand**.\n\nConsider this example:\n\n```javascript\n// Typical long format\nconsole.log(`${from.toLocaleString()} - ${to.toLocaleString()}`);\n// Output: \"1/1/2024, 00:00:00 AM - 1/12/2024, 23:59:59 PM\"\n\n// With little-date\nconsole.log(formatDateRange(from, to));\n// Output: \"Jan 1 - 12\"\n```\n\n`little-date` is based on [date-fns](https://date-fns.org/). It supports localization and can be used in both Node.js and the browser.\n\n**Examples dates ✨**\n\n- `Jan 1 - 12`\n- `Jan 3 - Apr 20`\n- `January 2023`\n- `Q1 2023`\n\nWasn't that easy to read? You can find a full list of formatting examples [here](#formatting-examples).\n\n## Usage\n\n```js\nimport { formatDateRange } from \"little-date\";\n\nconst from = new Date(\"2023-01-01T00:00:00.000Z\");\nconst to = new Date(\"2023-01-12T23:59:59.999Z\");\n\nformatDateRange(from, to); // Outputs: \"Jan 1 - 12\"\n```\n\n## Installation\n\n#### With pnpm\n\n```sh\npnpm i little-date\n```\n\n#### With NPM\n\n```sh\nnpm i little-date\n```\n\n## Formatting Examples\n\n| Description                               | Output                                   |\n| ----------------------------------------- | ---------------------------------------- |\n| Multiple days, same month                 | `Jan 1 - 12`                             |\n| Multiple days, different months           | `Jan 3 - Apr 20`                         |\n| Full day                                  | `Sun, Jan 1`                             |\n| Range spanning different years            | `Jan 1 '22 - Jan 20 '23`                 |\n| Multiple days, same month, past year      | `Jan 1 - 12, 2022`                       |\n| Full day, past year                       | `Sat, Jan 1, 2022`                       |\n| **Special cases**                         |                                          |\n| Full year                                 | `2023`                                   |\n| Quarter range                             | `Q1 2023`                                |\n| Full month                                | `January 2023`                           |\n| Full months                               | `Jan - Feb 2023`                         |\n| **With time**                             |                                          |\n| Today, different hours                    | `12am - 2:30pm`                          |\n| Same day, different hours                 | `Jan 1, 12:11am - 2:30pm`                |\n| Same day, different hours, 24-hour format | `Jan 1, 0:11 - 14:30`                    |\n| Hour difference within a day              | `Jan 1, 12pm - 12:59pm`                  |\n| Different days with time included         | `Jan 1, 12:11am - Jan 2, 2:30pm`         |\n| Different years with time                 | `Jan 1 '22, 12:11am - Jan 2 '23, 2:30pm` |\n| Different years, no time                  | `Jan 1 '22 - Jan 2 '23`                  |\n\n## Advanced Options\n\nMost of the formatting behavior is opinionated and can't be changed. However, there are some options that can be used to customize the output.\n\n```js\nimport { formatDateRange } from \"little-date\";\n\n// ...\n\nformatDateRange(from, to, {\n  locale: \"de-AT\", // Overwrite the default locale\n  includeTime: false, // Prevent time from being displayed\n  today: new Date(), // Overwrite the default \"today\" date, useful for testing\n  separator: \"-\", // Overwrite the default separator. E.g. from \"Jan 1 - 12\" to \"Jan 1 to 12\"\n});\n```\n\n## Customization\n\nTo keep things simple, there is minimal customization offered by `little-date`.\n\nFor more extensive customization beyond the provided options, it's recommended to copy the implementation from [`src/format-date-range.ts`](https://github.com/vercel/little-date/blob/main/src/format-date-range.ts) into your own repository. This allows you to modify the formatting logic to precisely fit your needs.\n\n## Contribute\n\nWe welcome contributions! If you'd like to improve `little-date` or have any feedback, feel free to open an issue or submit a pull request.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvercel%2Flittle-date","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvercel%2Flittle-date","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvercel%2Flittle-date/lists"}