{"id":15732510,"url":"https://github.com/jonschlinkert/is-valid-year","last_synced_at":"2025-03-31T03:42:04.418Z","repository":{"id":36064927,"uuid":"40364062","full_name":"jonschlinkert/is-valid-year","owner":"jonschlinkert","description":"Returns true if a year is valid based on a given year, range of years, sequences of years, or any mixture of these.","archived":false,"fork":false,"pushed_at":"2015-08-07T14:37:20.000Z","size":120,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T17:44:42.530Z","etag":null,"topics":["date","dates","range","validate","year"],"latest_commit_sha":null,"homepage":null,"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/jonschlinkert.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":"2015-08-07T14:22:35.000Z","updated_at":"2021-04-12T22:40:16.000Z","dependencies_parsed_at":"2022-09-13T18:31:56.248Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/is-valid-year","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fis-valid-year","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fis-valid-year/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fis-valid-year/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fis-valid-year/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/is-valid-year/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246413230,"owners_count":20773053,"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","dates","range","validate","year"],"created_at":"2024-10-04T00:20:37.902Z","updated_at":"2025-03-31T03:42:04.395Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","readme":"# is-valid-year [![NPM version](https://badge.fury.io/js/is-valid-year.svg)](http://badge.fury.io/js/is-valid-year)\n\n\u003e Returns true if a year is valid based on a given year, range of years, sequences of years, or any mixture of these. Useful for validating copyrights, dates that are parsed from physical documents, etc.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/)\n\n```sh\n$ npm i is-valid-year --save\n```\n\n## Usage\n\nSupports years as numbers or strings:\n\n```js\nvar isValidYear = require('is-valid-year');\n\nisValidYear(2011, '2010-2015');\n//=\u003e true\nisValidYear(2011, '1999-2001');\n//=\u003e false\n```\n\n**Acceptable formats**\n\nPass an array or list or years or year ranges (years must increase from left to right).\n\n* The first argument is the year to validate\n* Everything else is a valid year to test against\n* Year ranges must always be a string separated by `-`, as in `2001-2005`\n* Non-ranges (sequential or otherwise) may be separated by `,` or `|` when passed as a string, or as must be passed as individual array elements.\n\nAll of the following should work:\n\n```js\nisValidYear(2011, 2015);\n//=\u003e false\nisValidYear(2015, 2015);\n//=\u003e true\n\nisValidYear(2015, [1999, 2000, 2001]);\n//=\u003e false\nisValidYear(2001, [1999, 2000, 2001]);\n//=\u003e true\n\nisValidYear(2009, '2010-2015');\n//=\u003e false\nisValidYear(2010, '2010-2015');\n//=\u003e true\n\nisValidYear(2008, '2009,2010-2015');\n//=\u003e false\nisValidYear(2009, '2009,2010-2015');\n//=\u003e true\n\nisValidYear(2011, [1997, '1999-2009', 2010]);\n//=\u003e false\nisValidYear(2010, [1997, '1999-2009', 2010]);\n//=\u003e true\n```\n\n## Related projects\n\n* [expand-range](https://github.com/jonschlinkert/expand-range): Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See… [more](https://github.com/jonschlinkert/expand-range)\n* [fill-range](https://github.com/jonschlinkert/fill-range): Fill in a range of numbers or letters, optionally passing an increment or multiplier to… [more](https://github.com/jonschlinkert/fill-range)\n* [repeat-element](https://github.com/jonschlinkert/repeat-element): Create an array by repeating the given value n times.\n* [repeat-string](https://github.com/jonschlinkert/repeat-string): Repeat the given string n times. Fastest implementation for repeating a string.\n* [to-regex-range](https://github.com/jonschlinkert/to-regex-range): Returns a regex-compatible range from two numbers, min and max. Useful for creating regular expressions… [more](https://github.com/jonschlinkert/to-regex-range)\n\n## Running tests\n\nInstall dev dependencies:\n\n```sh\n$ npm i -d \u0026\u0026 npm test\n```\n\n## Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-valid-year/issues/new)\n\n## Author\n\n**Jon Schlinkert**\n\n+ [github/jonschlinkert](https://github.com/jonschlinkert)\n+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)\n\n## License\n\nCopyright © 2015 Jon Schlinkert\nReleased under the MIT license.\n\n***\n\n_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 07, 2015._","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fis-valid-year","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fis-valid-year","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fis-valid-year/lists"}