{"id":50682969,"url":"https://github.com/meltenc/week-identifier","last_synced_at":"2026-06-08T20:21:37.410Z","repository":{"id":57397606,"uuid":"65538561","full_name":"meltenc/week-identifier","owner":"meltenc","description":"Get unique and sequential week identifier of current date or given valid `Date` string format or Date object.","archived":false,"fork":false,"pushed_at":"2025-07-26T21:32:29.000Z","size":152,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-14T16:40:53.080Z","etag":null,"topics":["id","npm-package","week","week-identifier"],"latest_commit_sha":null,"homepage":"","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/meltenc.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":"2016-08-12T08:50:14.000Z","updated_at":"2025-07-21T22:50:36.000Z","dependencies_parsed_at":"2022-08-30T10:40:42.698Z","dependency_job_id":null,"html_url":"https://github.com/meltenc/week-identifier","commit_stats":null,"previous_names":["throll/week-identifier"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/meltenc/week-identifier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meltenc%2Fweek-identifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meltenc%2Fweek-identifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meltenc%2Fweek-identifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meltenc%2Fweek-identifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meltenc","download_url":"https://codeload.github.com/meltenc/week-identifier/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meltenc%2Fweek-identifier/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34079237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["id","npm-package","week","week-identifier"],"created_at":"2026-06-08T20:21:36.711Z","updated_at":"2026-06-08T20:21:37.405Z","avatar_url":"https://github.com/meltenc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## [![npm][npmjs-img]][npmjs-url] [![license][license-img]][license-url] [![build][build-img]][build-url] [![codecov][codecov-img]][codecov-url] [![downloads][downloads-img]][downloads-url]\n\n\u003e Get unique and sequential week identifier for any date. Modern ES6+ with robust error handling.\n\nWeek #1 starts on January 5, 1970 (Monday). Each week runs Monday to Sunday.\n\n## Install\n```bash\nnpm install week-identifier\n\n# Test the installation\nnpm test\n\n# Try the CLI\nweek-identifier --help\n```\n\n\n## API\n\u003e For comprehensive test examples see [test.js](./test.js) and [test-cli.js](./test-cli.js)\n\n### weekIdentifier(date?)\n\u003e Get sequential week identifier for any date\n\n- **date** `{string|Date}` - Date string (any valid format) or Date object (optional, defaults to current date)\n- **returns** `{number}` - Sequential week identifier (1-based)\n- **throws** `{Error}` - When provided date is invalid\n\n**Examples:**\n\n```js\nconst weekIdentifier = require('week-identifier');\n\n// Current week (depends on today's date)\nweekIdentifier();\n//=\u003e 2433\n\n// Week 1 (epoch start)\nweekIdentifier('January 5, 1970');\n//=\u003e 1\n\n// Various date formats supported\nweekIdentifier('January 12, 1970');\n//=\u003e 2\n\nweekIdentifier(new Date('August 12, 2016'));\n//=\u003e 2432\n\nweekIdentifier('08/12/2016');\n//=\u003e 2432\n\nweekIdentifier('August 12, 2016');\n//=\u003e 2432\n\n// Error handling for invalid dates\ntry {\n  weekIdentifier('invalid date');\n} catch (error) {\n  console.error(error.message);\n  //=\u003e 'Invalid date string: \"invalid date\"'\n}\n```\n\n### weekIdentifier.dateFromWeek(weekId)\n\u003e Convert week identifier back to its Monday date\n\n- **weekId** `{number|string}` - Week identifier to convert\n- **returns** `{Date}` - Monday date of the specified week\n- **throws** `{Error}` - When weekId is not a valid number\n\n**Examples:**\n\n```js\nconst weekIdentifier = require('week-identifier');\n\n// Get Monday of week 2433\nweekIdentifier.dateFromWeek(2433);\n//=\u003e Date object for August 15, 2016 00:00:00\n\n// Week 1 returns epoch start\nweekIdentifier.dateFromWeek(1);\n//=\u003e Date object for January 5, 1970 00:00:00\n\n// Week 0 or negative returns epoch start\nweekIdentifier.dateFromWeek(0);\n//=\u003e Date object for January 5, 1970 00:00:00\n\n// Error handling\ntry {\n  weekIdentifier.dateFromWeek('abc');\n} catch (error) {\n  console.error(error.message);\n  //=\u003e 'Invalid week identifier: \"abc\"'\n}\n```\n\n## CLI Usage\n\nThe package includes a powerful command-line interface with enhanced argument parsing.\n\n### Installation \u0026 Usage\n\n```bash\n# Install globally for CLI access\nnpm install -g week-identifier\n\n# Or use without installing\nnpx week-identifier\n```\n\n### Commands \u0026 Options\n\n```bash\n# Get current week identifier\nweek-identifier\n#=\u003e 2433\n\n# Get week identifier for specific dates  \nweek-identifier \"January 5, 1970\"\n#=\u003e 1\n\nweek-identifier \"August 12, 2016\"  \n#=\u003e 2432\n\nweek-identifier \"02/17/2012\"\n#=\u003e 2198\n\n# Convert week identifier back to date\nweek-identifier --from 2432\n#=\u003e 2016-08-08\n\nweek-identifier --from 1\n#=\u003e 1970-01-05\n\n# Get help and version info\nweek-identifier --help\nweek-identifier --version\n```\n\n### Error Handling\n\n```bash\n# Invalid date strings show helpful errors\nweek-identifier \"invalid date\"\n#=\u003e Error: Invalid date string: \"invalid date\"\n#=\u003e Use --help for usage information.\n\n# Invalid week identifiers are caught\nweek-identifier --from abc  \n#=\u003e Error: Invalid week identifier: \"abc\"\n#=\u003e Use --help for usage information.\n```\n\n\n## License [![MIT license][license-img]][license-url]\nCopyright (c) 2025 [Clément Billiot], [contributors][contrib-graf].  \nReleased under the [`MIT`][license-url] license.\n\n\n[npmjs-url]: http://npm.im/week-identifier\n[npmjs-img]: https://img.shields.io/npm/v/week-identifier.svg?style=flat\u0026label=week-identifier\n\n[license-url]: https://github.com/meltenc/week-identifier/blob/master/license.md\n[license-img]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat\n\n[build-url]: https://github.com/meltenc/week-identifier/actions/workflows/ci.yml\n[build-img]: https://img.shields.io/github/actions/workflow/status/meltenc/week-identifier/ci.yml?branch=master\u0026style=flat\n\n[codecov-url]: https://codecov.io/gh/meltenc/week-identifier\n[codecov-img]: https://img.shields.io/codecov/c/github/meltenc/week-identifier?style=flat\n\n[downloads-url]: https://npmjs.org/package/week-identifier\n[downloads-img]: https://img.shields.io/npm/dm/week-identifier.svg?style=flat\n\n[author-github]: https://github.com/meltenc\n\n[contrib-graf]: https://github.com/meltenc/week-identifier/graphs/contributors\n\n***\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeltenc%2Fweek-identifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeltenc%2Fweek-identifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeltenc%2Fweek-identifier/lists"}