{"id":13493070,"url":"https://github.com/lukeed/calendarize","last_synced_at":"2025-10-09T18:24:43.006Z","repository":{"id":57192918,"uuid":"235259286","full_name":"lukeed/calendarize","owner":"lukeed","description":"A tiny (202B) utility to generate calendar views.","archived":false,"fork":false,"pushed_at":"2020-01-23T17:47:12.000Z","size":12,"stargazers_count":478,"open_issues_count":0,"forks_count":9,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-01T20:06:11.390Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://codepen.io/lukeed/pen/KKwrLRz","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}},"created_at":"2020-01-21T04:56:42.000Z","updated_at":"2024-09-29T16:01:58.000Z","dependencies_parsed_at":"2022-09-01T06:00:44.856Z","dependency_job_id":null,"html_url":"https://github.com/lukeed/calendarize","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fcalendarize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fcalendarize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fcalendarize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fcalendarize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukeed","download_url":"https://codeload.github.com/lukeed/calendarize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222376246,"owners_count":16974312,"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-07-31T19:01:11.933Z","updated_at":"2025-10-09T18:24:37.962Z","avatar_url":"https://github.com/lukeed.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# calendarize [![build status](https://badgen.net/github/status/lukeed/calendarize)](https://github.com/lukeed/calendarize/actions) [![codecov](https://badgen.now.sh/codecov/c/github/lukeed/calendarize)](https://codecov.io/gh/lukeed/calendarize)\n\n\u003e A tiny (202B) utility to generate calendar views.\n\nThis function (optionally) accepts a date in exchange for a calendar view of that date's month.\n\n**The output contains no labels!** This is ideal for calendar generator because it allows the developer to easily customize their labels, including full i18n/internationalization support! ([Demo](https://codepen.io/lukeed/pen/KKwrLRz))\n\nAdditionally, this module is delivered as:\n\n* **ES Module**: [`dist/calendarize.mjs`](https://unpkg.com/calendarize/dist/index.mjs)\n* **CommonJS**: [`dist/calendarize.js`](https://unpkg.com/calendarize/dist/index.js)\n* **UMD**: [`dist/calendarize.min.js`](https://unpkg.com/calendarize)\n\n\n## Install\n\n```\n$ npm install --save calendarize\n```\n\n\n## Usage\n\n***via Date Instance***\n\n```js\nimport calendarize from 'calendarize';\n\n// Week = [Sun, Mon, Tue, Wed, Thu, Fri, Sat]\nconst view = calendarize(new Date('2019-12-20'));\n//=\u003e [\n//=\u003e   [ 1,  2,  3,  4,  5,  6,  7],\n//=\u003e   [ 8,  9, 10, 11, 12, 13, 14],\n//=\u003e   [15, 16, 17, 18, 19, 20, 21],\n//=\u003e   [22, 23, 24, 25, 26, 27, 28],\n//=\u003e   [29, 30, 31,  0,  0,  0,  0],\n//=\u003e ]\n```\n\n***via Date String***\n\n```js\nimport calendarize from 'calendarize';\n\n// Week = [Sun, Mon, Tue, Wed, Thu, Fri, Sat]\nconst view = calendarize('Nov 01, 2019');\n//=\u003e [\n//=\u003e   [ 0,  0,  0,  0,  0,  1,  2],\n//=\u003e   [ 3,  4,  5,  6,  7,  8,  9],\n//=\u003e   [10, 11, 12, 13, 14, 15, 16],\n//=\u003e   [17, 18, 19, 20, 21, 22, 23],\n//=\u003e   [24, 25, 26, 27, 28, 29, 30],\n//=\u003e ]\n```\n\n\n***with Weeks starting on Monday***\n\n\u003e **Note:** Uses the [`offset`](#offset) parameter.\n\n```js\nimport calendarize from 'calendarize';\n\n// Week = [Mon, Tue, Wed, Thu, Fri, Sat, Sun]\nconst view = calendarize('Nov 01, 2019', 1);\n//=\u003e [\n//=\u003e   [ 0,  0,  0,  0,  1,  2,  3],\n//=\u003e   [ 4,  5,  6,  7,  8,  9, 10],\n//=\u003e   [11, 12, 13, 14, 15, 16, 17],\n//=\u003e   [18, 19, 20, 21, 22, 23, 24],\n//=\u003e   [25, 26, 27, 28, 29, 30,  0],\n//=\u003e ]\n```\n\n\n## API\n\n### calendarize(date?, offset?)\nReturns: `Array\u003cWeek\u003e`\n\nAn Array of `Week` Arrays is returned.\n\nEach `Week` is an Array of 7 numbers, wherein each **index** is the `Day` of the week and each **value** is the numerical date. \u003cbr\u003eThe index is forwarded from [`Date.getDay`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay), which means that **index: 0** is Sunday.\n\n\u003e **Important:** A **value** of zero (`0`) represents a date that exists beyond the current month view.\n\n#### date\nType: `string` | `number` | `Date`\u003cbr\u003e\nDefault: `new Date()` – aka, today\n\nThe date you want to process.\n\n\u003e **Important**: Your `string|number` value will be cast to a `Date` object, which means Node.js may apply incorrect timezone!\n\n#### offset\nType: `number`\u003cbr\u003e\nDefault: `0`\n\nA positive or negative day offset to modify which day of the week the calendar should start.\u003cbr\u003e\nThis offset is ***relative to Sunday*** – so, by default, an offset of `0` will mean that your Weeks will start on Sundays.\n\n\u003e **Note:** Some parts of the globe expect calendars to start on Sunday, Saturday, or Monday: [see map](https://i.redd.it/qcz8nu53lk231.png)\n\n***Example Offsets***\n\n* Monday: `1`\n* Tuesday: `2`\n* ...\n* Friday: `5` or `-2`\n* Saturday: `6` or `-1`\n\nIf you use `offset: 1`, this means you want the `Week`s to start on Monday. In turn, the 0th value of each `Week` array will be Monday's date.\n\n```js\n// The first week of Jan 2020:\n\n// start = Sunday (default)\ncalendarize('Jan 01, 2020');\n// =\u003e    [[0, 0, 0, 1, 2, 3, 4], ...]\n// (days: [S, M, T, W, T, F, S])\n\n// start = Monday (offset: 1)\ncalendarize('Jan 01, 2020', 1);\n// =\u003e    [[0, 0, 1, 2, 3, 4, 5], ...]\n// (days: [M, T, W, T, F, S, S])\n```\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fcalendarize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukeed%2Fcalendarize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fcalendarize/lists"}