{"id":19474635,"url":"https://github.com/tomasc/date-queries","last_synced_at":"2025-10-10T03:35:48.642Z","repository":{"id":39494288,"uuid":"169471744","full_name":"tomasc/date-queries","owner":"tomasc","description":"JS function to check date or date range against common queries or custom functions.","archived":false,"fork":false,"pushed_at":"2022-12-10T02:18:17.000Z","size":1208,"stargazers_count":0,"open_issues_count":21,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-25T15:49:34.619Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","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/tomasc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-06T20:27:24.000Z","updated_at":"2019-09-09T15:52:05.000Z","dependencies_parsed_at":"2022-08-26T15:30:31.656Z","dependency_job_id":null,"html_url":"https://github.com/tomasc/date-queries","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tomasc/date-queries","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasc%2Fdate-queries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasc%2Fdate-queries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasc%2Fdate-queries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasc%2Fdate-queries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomasc","download_url":"https://codeload.github.com/tomasc/date-queries/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasc%2Fdate-queries/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002622,"owners_count":26083425,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"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":[],"created_at":"2024-11-10T19:25:56.275Z","updated_at":"2025-10-10T03:35:48.626Z","avatar_url":"https://github.com/tomasc.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Date Queries\n\n[![Build Status](https://travis-ci.org/tomasc/date-queries.svg)](https://travis-ci.org/tomasc/date-queries) [![npm version](https://badge.fury.io/js/date-queries.svg)](https://badge.fury.io/js/date-queries)\n\nJS function to check date or date range against common queries or custom functions.\n\n## Getting Started\n\nInstall:\n\n```\nyarn add date-queries\n```\n\n## How to use\n\nPass `dtstart` and `dtend` (`dtend` can be set to `undefined`) and queries to check the dates against.\n\nThe queries can be either one of the predefined (see below) or a custom function that accepts `dtstart` and `dtend` and returns a value (typically string) if truthy.\n\nThe `dateQueries` function returns name of the first matching query (for example `tomorrow`) or value of the custom function. Queries are evaluated in order as specified.\n\n```coffee\nqueries = [\n  'today',\n  'tomorrow',\n  'this-week'\n]\n\n# dateQueries(dtstart, dtend, queries)\ndateQueries(new Date(), null, queries) # =\u003e 'today'\n```\n\nWith custom function:\n\n```coffee\nimport { isWednesday, isWithinRange, setDay } from 'date-fns'\n\nqueries = [\n  ((dtstart, dtend) -\u003e\n    if dtend\n      # does the range cover coming Wednesday?\n      isWithinRange(setDay(new Date(), 3), dtstart, dtend)\n    else\n      isWednesday(dtstart)\n  )\n]\n\ndateQueries(dtstart, dtend, queries)\n```\n\n## Available queries\n\n* `now`, `today`\n* `tomorrow`\n* `yesterday`\n* `this-week`\n* `next-week`\n* `past-week`\n* `this-month`\n* `next-month`\n* `past-month`\n* `this-year`\n* `next-year`\n* `past-year`\n* `next`\n* `past`\n* `nearest-weekend`\n* `weekend`\n* `rest-of-this-week`\n\n## Development\n\nRunning the tests:\n\n```\nyarn test\nyarn test --watch\n```\n\n## Building\n\n```\nyarn build\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at \u003chttps://github.com/tomasc/date-queries\u003e.\n\n## License\n\nThe library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomasc%2Fdate-queries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomasc%2Fdate-queries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomasc%2Fdate-queries/lists"}