{"id":16679750,"url":"https://github.com/buren/blackcal","last_synced_at":"2025-08-14T12:44:54.361Z","repository":{"id":62554321,"uuid":"148941147","full_name":"buren/blackcal","owner":"buren","description":"Create blacklist rules for calendars with ease.","archived":false,"fork":false,"pushed_at":"2021-11-29T05:19:44.000Z","size":123,"stargazers_count":6,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T20:00:24.944Z","etag":null,"topics":["calendar","rubygem","schedule"],"latest_commit_sha":null,"homepage":null,"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/buren.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":"2018-09-15T21:24:20.000Z","updated_at":"2023-05-24T14:04:40.000Z","dependencies_parsed_at":"2022-11-03T05:00:31.463Z","dependency_job_id":null,"html_url":"https://github.com/buren/blackcal","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/buren/blackcal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buren%2Fblackcal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buren%2Fblackcal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buren%2Fblackcal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buren%2Fblackcal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/buren","download_url":"https://codeload.github.com/buren/blackcal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buren%2Fblackcal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270422594,"owners_count":24580831,"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-14T02:00:10.309Z","response_time":75,"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":["calendar","rubygem","schedule"],"created_at":"2024-10-12T13:37:19.929Z","updated_at":"2025-08-14T12:44:54.329Z","avatar_url":"https://github.com/buren.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blackcal [![Build Status](https://travis-ci.com/buren/blackcal.svg?branch=master)](https://travis-ci.com/buren/blackcal)\n\nCreate blacklist rules for calendars with ease. Supports recurring rules for certain weekdays, date numbers, hour of day.\n\nBorn from the idea of comparing schedules using matrix operations. This gem makes it easy to see whether if a time is covered by a certain schedule and generate a matrix representing what the schedule covers (hour our minute resolution).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'blackcal'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install blackcal\n\n## Usage\n\nThe main parts are `Blackcal#schedule` for generating a schedule, `schedule#cover?` to see whether a time is covered by schedule and finally `schedule#to_matrix` that generates a schedule with given time resolution (hour our minute).\n\nSchedule Mondays and Tuesdays\n```ruby\nschedule = Blackcal.schedule(weekdays: [:monday, :tuesday])\nschedule.cover?('2019-01-01 19:00')\n# =\u003e true\nschedule.cover?('2019-01-02 19:00')\n# =\u003e false\n```\n\nSchedule between 6pm and 7am every day\n```ruby\nschedule = Blackcal.schedule(start_time_of_day: 18, finish_time_of_day: 7)\nschedule.cover?('2019-01-01 19:00')\n# =\u003e true\nschedule.cover?('2019-01-01 11:00')\n# =\u003e false\n\n# minutes are supported too\neighteen_thirty = Blackcal::TimeOfDay.new(18, 30)\nschedule = Blackcal.schedule(start_time_of_day: eighteen_thirty)\n```\n\nSchedule day 15 and 17 of month\n```ruby\nschedule = Blackcal.schedule(days: [15, 17])\nschedule.cover?('2019-01-15 19:00')\n# =\u003e true\nschedule.cover?('2019-01-01 11:00')\n# =\u003e false\n```\n\nSchedule first and third week of every month\n```ruby\nschedule = Blackcal.schedule(weeks_of_month: [1, 3])\nschedule.cover?('2019-01-03 19:00')\n# =\u003e true\nschedule.cover?('2019-01-10 19:00')\n# =\u003e false\n```\n\nDefine when the schedule is active\n```ruby\nBlackcal.schedule(start_time: '2018-01-01 11:00', finish_time: '2019-01-01 11:00')\n```\n\nAll options at once - schedule January, 3rd week, Mondays and Tuesdays, day 15-25, between 18pm and 7am\n```ruby\nschedule = Blackcal.schedule(\n  months: [:january],\n  weeks_of_month: [3],\n  weekdays: [:monday, :tuesday],\n  start_time_of_day: 18,\n  finish_time_of_day: 7.30, # use floats to represent hour/min\n  days: 15..25\n)\nschedule.cover?('2018-01-16 06:00')\n# =\u003e true\nschedule.cover?('2018-01-16 08:00')\n# =\u003e false\n```\n\n_Note_: `#cover?` supports `String` and `Time` objects. `start_time_of_day` and `finish_time_of_day` supports `Blackcal::TimeOfDay`, `Time` and `Integer` objects.\n\nBuilder pattern\n```ruby\nBlackcal.schedule do\n  months [:january]\n  weeks_of_month [3]\n  weekdays [:monday, :tuesday]\n  start_time_of_day 18\n  finish_time_of_day 7\n  days 15..25\nend\n# you can, though not recommended, mix arguments with the\n# builder data from the builder will override the arguments\nBlackcal.schedule(days: [14, 21]) do\n  months [:january]\nend\n```\n\nMatrix representation\n```ruby\nschedule = Blackcal.schedule(weekdays: :friday, start_time_of_day: 0, finish_time_of_day: 14)\nschedule.to_matrix(start_date: '2018-09-14', finish_date: '2018-09-16')\n# =\u003e [[true, ...], [false, ...]]\n\n# defaults to hour resolution, but you can get minute resolution too\nschedule = Blackcal.schedule(weekdays: :friday, start_time_of_day: 0, finish_time_of_day: 14)\nschedule.to_matrix(resolution: :min, start_date: '2018-09-14', finish_date: '2018-09-16')\n# =\u003e [[true, ...], [false, ...]]\n```\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 `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/buren/blackcal.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburen%2Fblackcal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fburen%2Fblackcal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburen%2Fblackcal/lists"}