{"id":21716844,"url":"https://github.com/placek/recurring_date","last_synced_at":"2026-04-21T09:33:22.806Z","repository":{"id":52314655,"uuid":"249420957","full_name":"placek/recurring_date","owner":"placek","description":"Iterate over a set of dates, giving an iteration conditions.","archived":false,"fork":false,"pushed_at":"2021-04-30T20:29:58.000Z","size":97,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-26T19:47:20.274Z","etag":null,"topics":["date","enumerator"],"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/placek.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-03-23T12:10:59.000Z","updated_at":"2020-03-24T06:29:53.000Z","dependencies_parsed_at":"2022-08-22T14:20:38.063Z","dependency_job_id":null,"html_url":"https://github.com/placek/recurring_date","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/placek/recurring_date","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/placek%2Frecurring_date","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/placek%2Frecurring_date/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/placek%2Frecurring_date/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/placek%2Frecurring_date/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/placek","download_url":"https://codeload.github.com/placek/recurring_date/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/placek%2Frecurring_date/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32085536,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T06:27:27.065Z","status":"ssl_error","status_checked_at":"2026-04-21T06:27:21.250Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["date","enumerator"],"created_at":"2024-11-26T01:14:05.859Z","updated_at":"2026-04-21T09:33:22.770Z","avatar_url":"https://github.com/placek.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# recurring_date\n\n[![Gem Version](https://badge.fury.io/rb/recurring_date.svg)](https://badge.fury.io/rb/recurring_date)\n[![Build Status](https://travis-ci.org/placek/recurring_date.svg?branch=master)](https://travis-ci.org/placek/recurring_date)\n[![Maintainability](https://api.codeclimate.com/v1/badges/8b2339034c78677126e7/maintainability)](https://codeclimate.com/github/placek/recurring_date/maintainability)\n\nIterate over a set of dates, giving an iteration conditions.\n\nThis gem provides an enumerator `RecurringDate::Enumerator`, selecting specific dates due to the recursion pattern.\n\n`RecurringDate::Enumerator` is lazy so pattern can be applied to an infinite set of dates.\n\nThe enumerator operates on objects that implements the `Enumerator#each` and yields `Date`.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'recurring_date'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install recurring_date\n\n## Usage\n\nSee [documentation](https://www.rubydoc.info/gems/recurring_date) for details.\n\n### `RecurringDate`\n\n`RecurringDate` module adds two methods to class `Date`:\n\n| Method     | Description\n|------------|-------------\n| `#mweek`   | Returns a number - n'th occurence of the week day in the month.\n| `#to_enum` | Returns `RecurringDate::Enumerator` enumerator with given range from `self` iterating forever (infinite set).\n\n### `RecurringDate::Enumerator`\n\nThe enumerator implements bunch of chainable methods to provide simple DSL for selecting wanted recursion pattern.\n\n| Pattern                                                  | DSL\n|----------------------------------------------------------|-----\n| dates matching `condition`                               | `enumerator.select { ❘d❘ condition }`\n| dates not matching `condition`                           | `enumerator.reject { ❘d❘ condition }`\n| dates matching `condition` (with index `i`)              | `enumerator.select_with_index { ❘d, i❘ condition }`\n| dates from beginning as long as `condition` is fulfilled | `enumerator.take_while { ❘d❘ condition }`\n| `n` dates from beginning                                 | `enumerator.take(n)`\n| every 4th of October                                     | `enumerator.month(10).mday(4)`\n| every 3rd and 23rd of August                             | `enumerator.month(8).mday(3, 23)`\n| every 17th June and July                                 | `enumerator.month(6, 7).mday(17)`\n| every 10th and 12th of February and April                | `enumerator.month(2, 4).mday(10, 12)`\n| every 13th of the month                                  | `enumerator.mday(13)`\n| every 21st and 23rd of the month                         | `enumerator.mday(21, 23)`\n| every Friday                                             | `enumerator.wday(5)`\n| every Saturday and Sunday                                | `enumerator.wday(6, 0)`\n| every Saturday and Sunday                                | `enumerator.matching(6, 0) { ❘d❘ d.wday }`\n| every Saturday and Sunday                                | `enumerator.matching(6, 0, \u0026:wday)`\n| every 4th day                                            | `enumerator.pattern(4)`\n| every 7th or 10th day                                    | `enumerator.pattern(7, 10)`\n| every second Friday                                      | `enumerator.wday(5).pattern(2)`\n| every 2nd Monday of the month                            | `enumerator.wday(1).mweek(2)`\n| 2nd and 4th Sunday of the month                          | `enumerator.wday(0).mweek(2,4)`\n| 3rd Tuesday and Wednesday of the month                   | `enumerator.wday(2,3).mweek(3)`\n| until `date`                                             | `enumerator.until(date)`\n\n###### NOTE\n\n* There is a method `RecurringDate::Enumerator.eternity` that returns `RecurringDate::Enumerator` instance that iterates perpetualy over every day after _1970-01-01_.\n* The `RecurringDate::Enumerator.from(date)` method does the same, but from `date`.\n* Every enumerator method (except `select`, `select_with_index`, `reject`, `take`, `take_while` and `until`) has a corresponding method with `not_` prefix.\n* For `rails` models the pattern can be used to select records, like: `Model.where('column::date IN (?)', dates)`.\n\n### Example\n\n    require 'recurring_date'\n    rule = RecurringDate::Enumerator.eternity\n    rule.wday(5).mweek(1)                       # =\u003e enumerator of all first Fridays of a month\n    rule.pattern(2).until(Date.new(2020, 8, 1)) # =\u003e enumerator of every second day until 2020-08-01\n    rule.wday(6,0).mweek(2,4).take(8)           # =\u003e enumerator of next four 2nd and 4th weekends of a month\n    rule.to_a                                   # =\u003e array of `Date` instances (be careful - it can be infinite)\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `lib/recurring_date/version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/placek/recurring_date.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplacek%2Frecurring_date","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplacek%2Frecurring_date","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplacek%2Frecurring_date/lists"}