{"id":13394027,"url":"https://github.com/lukeed/tinydate","last_synced_at":"2025-05-15T00:12:30.015Z","repository":{"id":39098024,"uuid":"89977123","full_name":"lukeed/tinydate","owner":"lukeed","description":"A tiny (349B) reusable date formatter. Extremely fast!","archived":false,"fork":false,"pushed_at":"2024-01-20T17:52:53.000Z","size":49,"stargazers_count":1069,"open_issues_count":2,"forks_count":16,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-06T17:08:58.470Z","etag":null,"topics":["date","datetime","format","javascript","time","timestamp"],"latest_commit_sha":null,"homepage":"https://jsfiddle.net/lukeed/aoy0xeze/","language":"JavaScript","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/lukeed.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}},"created_at":"2017-05-02T01:09:25.000Z","updated_at":"2025-03-28T17:45:02.000Z","dependencies_parsed_at":"2024-02-04T15:11:18.090Z","dependency_job_id":null,"html_url":"https://github.com/lukeed/tinydate","commit_stats":{"total_commits":48,"total_committers":2,"mean_commits":24.0,"dds":0.02083333333333337,"last_synced_commit":"a91f2b03afabcdf457baecb14937fe2cad7ea955"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Ftinydate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Ftinydate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Ftinydate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Ftinydate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukeed","download_url":"https://codeload.github.com/lukeed/tinydate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248225704,"owners_count":21068078,"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":["date","datetime","format","javascript","time","timestamp"],"created_at":"2024-07-30T17:01:06.310Z","updated_at":"2025-04-13T20:44:06.609Z","avatar_url":"https://github.com/lukeed.png","language":"JavaScript","readme":"# tinydate ![CI](https://github.com/lukeed/tinydate/workflows/CI/badge.svg) [![licenses](https://licenses.dev/b/npm/tinydate)](https://licenses.dev/npm/tinydate) [![downloads](https://badgen.now.sh/npm/dm/tinydate)](https://npmjs.org/package/tinydate)\n\n\u003e A tiny (349B) reusable date formatter. Extremely fast!\n\n[Demo](https://jsfiddle.net/lukeed/aoy0xeze/)\n\nInspired by [`tinytime`][tinytime], this module returns a \"render\" function that efficiently re-render your deconstructed template. This allows for [incredibly performant](#benchmarks) results!\n\nHowever, please notice that this only provides a [limited subset of Date methods](#patterns).\u003cbr\u003e\nIf you need more, [`tinytime`][tinytime] or [`date-fns`](https://github.com/date-fns/date-fns) are great alternatives!\n\n## Install\n\n```\n$ npm install --save tinydate\n```\n\n\n## Usage\n\n```js\nconst tinydate = require('tinydate');\nconst fooDate = new Date('5/1/2017, 4:30:09 PM');\n\nconst stamp = tinydate('Current time: [{HH}:{mm}:{ss}]');\n\nstamp(fooDate);\n//=\u003e Current time: [16:30:09]\n\nstamp();\n//=\u003e Current time: [17:09:34]\n```\n\n\n## API\n\n### tinydate(pattern, dict?)(date?)\nReturns: `Function`\n\nReturns a rendering function that will optionally accept a [`date`](#date) value as its only argument.\n\n#### pattern\nType: `String`\u003cbr\u003e\nRequired: `true`\n\nThe template pattern to be parsed.\n\n#### dict\nType: `Object`\u003cbr\u003e\nRequired: `false`\n\nA custom dictionary of template patterns. You may override [existing patterns](#patterns) or declare new ones.\n\n\u003e **Important:** All dictionary items **must be a function** and must control its own formatting.\u003cbr\u003eFor example, when defining your own `{ss}` template, `tinydate` **will not** pad its value to two digits.\n\n```js\nconst today = new Date('2019-07-04, 5:30:00 PM');\n\n// Example custom dictionary:\n//   - Adds {MMMM}\n//   - Overrides {DD}\nconst stamp = tinydate('Today is: {MMMM} {DD}, {YYYY}', {\n\tMMMM: d =\u003e d.toLocaleString('default', { month: 'long' }),\n\tDD: d =\u003e d.getDate()\n});\n\nstamp(today);\n//=\u003e 'Today is: July 4, 2019'\n```\n\n#### date\nType: `Date`\u003cbr\u003e\nDefault: `new Date()`\n\nThe date from which to retrieve values. Defaults to current datetime if no value is provided.\n\n\n## Patterns\n\n- `{YYYY}`: full year; eg: **2017**\n- `{YY}`: short year; eg: **17**\n- `{MM}`: month; eg: **04**\n- `{DD}`: day; eg: **01**\n- `{HH}`: hours; eg: **06** (24h)\n- `{mm}`: minutes; eg: **59**\n- `{ss}`: seconds; eg: **09**\n- `{fff}`: milliseconds; eg: **555**\n\n\n## Benchmarks\n\n```\n# Node v10.13.0\n\ntinydate    x 160,834,214 ops/sec ±0.21% (96 runs sampled)\ntinytime    x  44,602,162 ops/sec ±0.34% (97 runs sampled)\ntime-stamp  x     888,153 ops/sec ±1.27% (86 runs sampled)\n```\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n\n[tinytime]: https://github.com/aweary/tinytime\n","funding_links":[],"categories":["JavaScript","Packages","Framework agnostic packages","Dates and Time"],"sub_categories":["Date","Reactive Programming"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Ftinydate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukeed%2Ftinydate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Ftinydate/lists"}