{"id":15642726,"url":"https://github.com/907th/datetime-scopes","last_synced_at":"2025-08-04T15:33:25.276Z","repository":{"id":149974511,"uuid":"44434991","full_name":"907th/datetime-scopes","owner":"907th","description":"A plugin for ActiveRecord which adds very helpful methods for querying records over time ranges (weeks/days/months/years), and it also respects time-zones!","archived":false,"fork":false,"pushed_at":"2016-02-07T19:25:14.000Z","size":30,"stargazers_count":16,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-30T10:04:32.222Z","etag":null,"topics":["activerecord","rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/907th.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2015-10-17T11:43:07.000Z","updated_at":"2024-03-29T17:30:07.000Z","dependencies_parsed_at":"2023-04-28T17:00:38.571Z","dependency_job_id":null,"html_url":"https://github.com/907th/datetime-scopes","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/907th/datetime-scopes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/907th%2Fdatetime-scopes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/907th%2Fdatetime-scopes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/907th%2Fdatetime-scopes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/907th%2Fdatetime-scopes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/907th","download_url":"https://codeload.github.com/907th/datetime-scopes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/907th%2Fdatetime-scopes/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268715299,"owners_count":24295296,"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-08-04T02:00:09.867Z","response_time":79,"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":["activerecord","rails"],"created_at":"2024-10-03T11:57:18.914Z","updated_at":"2025-08-04T15:33:25.219Z","avatar_url":"https://github.com/907th.png","language":"Ruby","readme":"# Date/time scopes for ActiveRecord models\n\n[![Gem Version](https://badge.fury.io/rb/datetime-scopes.svg)](https://badge.fury.io/rb/datetime-scopes)\n[![Build Status](https://travis-ci.org/907th/datetime-scopes.svg?branch=master)](https://travis-ci.org/907th/datetime-scopes)\n[![Code Climate](https://codeclimate.com/github/907th/datetime-scopes/badges/gpa.svg)](https://codeclimate.com/github/907th/datetime-scopes)\n[![Test Coverage](https://codeclimate.com/github/907th/datetime-scopes/badges/coverage.svg)](https://codeclimate.com/github/907th/datetime-scopes/coverage)\n\nDate/time scopes for ActiveRecord models you always missed! With proper time-zones support.\n\n## Quick start\n\n```ruby\n# Gemfile\ngem \"datetime-scopes\"\n```\n\n```ruby\n# app/models/my_model.rb\nclass MyModel \u003c ActiveRecord::Base\n  datetime_scopes :created_at  # with 'datetime' typed attribute\n  date_scopes :birthday        # with 'date' typed attribute\nend\n```\n\nNow your model has these scopes:\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\n      for \u003cb\u003ecreated_at\u003c/b\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      for \u003cb\u003ebirthday\u003c/b\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd valign=\"top\"\u003e\n      \u003cul\u003e\n        \u003cli\u003ecreated_within(from, to)\u003c/li\u003e\n        \u003cli\u003ecreated_within_days(from, to)\u003c/li\u003e\n        \u003cli\u003ecreated_within_months(from, to)\u003c/li\u003e\n        \u003cli\u003ecreated_within_years(from, to)\u003c/li\u003e\n        \u003cli\u003ecreated_on_day(t)\u003c/li\u003e\n        \u003cli\u003ecreated_on_month(t)\u003c/li\u003e\n        \u003cli\u003ecreated_on_year(t)\u003c/li\u003e\n        \u003cli\u003ecreated_before(t)\u003c/li\u003e\n        \u003cli\u003ecreated_before_day(t)\u003c/li\u003e\n        \u003cli\u003ecreated_before_month(t)\u003c/li\u003e\n        \u003cli\u003ecreated_before_year(t)\u003c/li\u003e\n        \u003cli\u003ecreated_after(t)\u003c/li\u003e\n        \u003cli\u003ecreated_after_day(t)\u003c/li\u003e\n        \u003cli\u003ecreated_after_month(t)\u003c/li\u003e\n        \u003cli\u003ecreated_after_year(t)\u003c/li\u003e\n        \u003cli\u003ecreated_on_or_before(t)\u003c/li\u003e\n        \u003cli\u003ecreated_on_or_before_day(t)\u003c/li\u003e\n        \u003cli\u003ecreated_on_or_before_month(t)\u003c/li\u003e\n        \u003cli\u003ecreated_on_or_before_year(t)\u003c/li\u003e\n        \u003cli\u003ecreated_on_or_after(t)\u003c/li\u003e\n        \u003cli\u003ecreated_on_or_after_day(t)\u003c/li\u003e\n        \u003cli\u003ecreated_on_or_after_month(t)\u003c/li\u003e\n        \u003cli\u003ecreated_on_or_after_year(t)\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/td\u003e\n    \u003ctd valign=\"top\"\u003e\n      \u003cul\u003e\n        \u003cli\u003ebirthday_within_days(from, to)\u003c/li\u003e\n        \u003cli\u003ebirthday_within_months(from, to)\u003c/li\u003e\n        \u003cli\u003ebirthday_within_years(from, to)\u003c/li\u003e\n        \u003cli\u003ebirthday_on_day(t)\u003c/li\u003e\n        \u003cli\u003ebirthday_on_month(t)\u003c/li\u003e\n        \u003cli\u003ebirthday_on_year(t)\u003c/li\u003e\n        \u003cli\u003ebirthday_before_day(t)\u003c/li\u003e\n        \u003cli\u003ebirthday_before_month(t)\u003c/li\u003e\n        \u003cli\u003ebirthday_before_year(t)\u003c/li\u003e\n        \u003cli\u003ebirthday_after_day(t)\u003c/li\u003e\n        \u003cli\u003ebirthday_after_month(t)\u003c/li\u003e\n        \u003cli\u003ebirthday_after_year(t)\u003c/li\u003e\n        \u003cli\u003ebirthday_on_or_before_day(t)\u003c/li\u003e\n        \u003cli\u003ebirthday_on_or_before_month(t)\u003c/li\u003e\n        \u003cli\u003ebirthday_on_or_before_year(t)\u003c/li\u003e\n        \u003cli\u003ebirthday_on_or_after_day(t)\u003c/li\u003e\n        \u003cli\u003ebirthday_on_or_after_month(t)\u003c/li\u003e\n        \u003cli\u003ebirthday_on_or_after_year(t)\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nExamples:\n\n```ruby\n# All records created yesterday (in current `::Time.zone`)\nMyModel.created_on_day(Date.yesterday)\n\n# Records created since 11 Sep 2001 (in current `::Time.zone`)\nMyModel.created_on_or_after(\"2001.09.11\")\n\n# Records create since 11 Sep 2001 (in New York). Yes, the result may differ to previous example!\nMyModel.created_on_or_after(\"2001.09.11\", time_zone: \"Eastern Time (US \u0026 Canada)\")\n\n# Records with birthday in 2015\nMyModel.birthday_on_year(Date.new 2015)\n```\n\n## Time-zone support\n\nYou know, when it is Sunday in San Francisco, it is Monday in Manila!\nAll parameters passed to a date/time scopes are first converted to a\nproject-specific (`::Time.zone`) or specified (`time_zone: \"XXX\"` param) time-zone with the help\nof magic ActiveSupport's `#in_time_zone` helper. See `rake time:zones:all` for\nall supported time-zones.\n\n## Additional options\n\nYou can pass a default time-zone and custom scopes' prefix to a `date(time)_scopes` method:\n\n```ruby\n# app/models/my_model.rb\nclass MyModel \u003c ActiveRecord::Base\n  datetime_scopes :created_at, prefix: \"issued\", time_zone: \"Ekaterinburg\"\nend\n\n# All records created yesterday (in Ekaterinburg)\nMyModel.issued_on_day(Date.yesterday)\n```\n\n## TODO\n\n- Complete pending tests!\n- ...\n\n## Contributing\n\nAny feedback is welcome!\n\n## License\n\nDistributed under the MIT License (see LICENSE.txt).\n\nCopyright \u0026copy; 2015. Alexey Chernenkov\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F907th%2Fdatetime-scopes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F907th%2Fdatetime-scopes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F907th%2Fdatetime-scopes/lists"}