{"id":15405138,"url":"https://github.com/fnando/time_window","last_synced_at":"2025-10-11T19:02:22.717Z","repository":{"id":62559011,"uuid":"161193823","full_name":"fnando/time_window","owner":"fnando","description":"Retrieve time objects by time windows (e.g. TimeWindow.call('5m') will round minutes to multiples of 5).","archived":false,"fork":false,"pushed_at":"2020-09-24T07:43:52.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-07T01:22:23.599Z","etag":null,"topics":["ruby","time","time-series","time-windows"],"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/fnando.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["fnando"],"custom":["https://www.paypal.me/nandovieira/🍕"]}},"created_at":"2018-12-10T15:15:33.000Z","updated_at":"2020-09-24T07:43:55.000Z","dependencies_parsed_at":"2022-11-03T11:15:32.512Z","dependency_job_id":null,"html_url":"https://github.com/fnando/time_window","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Ftime_window","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Ftime_window/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Ftime_window/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Ftime_window/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnando","download_url":"https://codeload.github.com/fnando/time_window/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245955190,"owners_count":20699889,"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":["ruby","time","time-series","time-windows"],"created_at":"2024-10-01T16:15:10.528Z","updated_at":"2025-10-11T19:02:17.662Z","avatar_url":"https://github.com/fnando.png","language":"Ruby","funding_links":["https://github.com/sponsors/fnando","https://www.paypal.me/nandovieira/🍕"],"categories":[],"sub_categories":[],"readme":"# TimeWindow\n\n[![Travis-CI](https://travis-ci.org/fnando/time_window.svg)](https://travis-ci.org/fnando/time_window)\n[![CodeClimate](https://codeclimate.com/github/fnando/time_window.svg)](https://codeclimate.com/github/fnando/time_window)\n[![Test Coverage](https://codeclimate.com/github/fnando/time_window/badges/coverage.svg)](https://codeclimate.com/github/fnando/time_window/coverage)\n[![Gem](https://img.shields.io/gem/v/time_window.svg)](https://rubygems.org/gems/time_window)\n[![Gem](https://img.shields.io/gem/dt/time_window.svg)](https://rubygems.org/gems/time_window)\n\nRetrieve time objects by time windows (e.g. TimeWindow.call('5m') will round\nminutes to multiples of 5).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'time_window'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install time_window\n\n## Usage\n\nYou can get a time window for any given time object. By default, it uses\n`Time.now`.\n\n```ruby\nrequire \"time_window\"\n\nTime.now\n#=\u003e 2018-12-10 07:07:14 -0800\n\nTimeWindow.call(\"5m\")\n#=\u003e 2018-12-10 07:05:00 -0800\n```\n\nYou can use the following units as time windows:\n\n- `s`: second\n- `m`: minute\n- `h`: hour\n\nTo specify a custom time object, just pass a second argument.\n\n```ruby\nTimeWindow.call \"15m\", Time.parse(\"2032-11-23T14:55:26\")\n#=\u003e 2032-11-23 14:45:00 -0800\n```\n\nBy default, `Time.now` is used as the default time. You can override the\ngenerator by setting `TimeWindow.now_proc`.\n\n```ruby\n# https://api.rubyonrails.org/classes/Time.html#method-c-current\nTimeWindow.now_proc = -\u003e { Time.current }\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run\n`rake test` to run the tests. You can also run `bin/console` for an interactive\nprompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To\nrelease a new version, update the version number in `version.rb`, and then run\n`bundle exec rake release`, which will create a git tag for the version, push\ngit commits and tags, and push the `.gem` file to\n[rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at\nhttps://github.com/fnando/time_window. This project is intended to be a safe,\nwelcoming space for collaboration, and contributors are expected to adhere to\nthe [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the\n[MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the TimeWindow project’s codebases, issue trackers, chat\nrooms and mailing lists is expected to follow the\n[code of conduct](https://github.com/fnando/time_window/blob/main/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Ftime_window","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnando%2Ftime_window","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Ftime_window/lists"}