{"id":13521066,"url":"https://github.com/allenan/human_time","last_synced_at":"2025-08-20T01:31:40.532Z","repository":{"id":56876965,"uuid":"65765441","full_name":"allenan/human_time","owner":"allenan","description":"Ruby time and date comparisons for humans","archived":false,"fork":false,"pushed_at":"2016-08-25T17:10:39.000Z","size":15,"stargazers_count":111,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-26T05:51:50.013Z","etag":null,"topics":["datetime","rspec-matchers","ruby","time"],"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/allenan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-15T21:13:48.000Z","updated_at":"2024-10-31T02:03:21.000Z","dependencies_parsed_at":"2022-08-20T11:31:04.154Z","dependency_job_id":null,"html_url":"https://github.com/allenan/human_time","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenan%2Fhuman_time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenan%2Fhuman_time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenan%2Fhuman_time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenan%2Fhuman_time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allenan","download_url":"https://codeload.github.com/allenan/human_time/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229956869,"owners_count":18150860,"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":["datetime","rspec-matchers","ruby","time"],"created_at":"2024-08-01T06:00:27.887Z","updated_at":"2024-12-19T05:07:47.075Z","avatar_url":"https://github.com/allenan.png","language":"Ruby","readme":"# human_time\n\n[![Build Status](https://travis-ci.org/allenan/human_time.svg?branch=master)](https://travis-ci.org/allenan/human_time)\n[![Gem Version](https://badge.fury.io/rb/human_time.svg)](https://badge.fury.io/rb/human_time)\n\nHave you ever struggled to understand what a piece of code like this is trying to say?\n\n```ruby\nsome_time \u003e another_time\n```\n\nIt should be simple, but our brains don't think in terms of \"greater than\" or \"less than\" when it comes to times and dates.\n\nhuman_time lets you express time comparison the way your human brain thinks:\n\n```ruby\nsome_time.more_recent_than?(another_time)\n```\n\nIt also includes some synonyms so you can word it in a way that makes sense to your human brain:\n\n```ruby\nsome_time.newer_than?(another_time)\nsome_time.comes_after?(another_time)\n```\n\nFor a complete list of expressions, see the 'Usage' section below.\n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'human_time'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install human_time\n\n## Usage\n\nhuman_time simply adds aliases for the `\u003e`, `\u003e=`, `\u003c` and `\u003c=` methods on the `Date`, `Time` and `DateTime` classes.\n\n```ruby\nolder_date = Date.parse('2016-01-01')\nnewer_date = Date.parse('2016-01-02')\n\nolder_date \u003c newer_date\n# =\u003e true\n\nolder_date.older_than?(newer_date)\n# =\u003e true\n\nnewer_date \u003e older_date\n# =\u003e true\n\nnewer_date.newer_than?(older_date)\n# =\u003e true\n```\n\n### `\u003e` aliases\n\n- `newer_than?`\n- `more_recent_than?`\n- `comes_after?`\n- `later_than?`\n\n### `\u003e=` aliases\n\n- `newer_than_or_equal_to?`\n- `more_recent_than_or_equal_to?`\n- `after_or_equal_to?`\n- `later_than_or_equal_to?`\n\n### `\u003c` aliases\n\n- `older_than?`\n- `comes_before?`\n- `earlier_than?`\n\n### `\u003c=` aliases\n\n- `older_than_or_equal_to?`\n- `before_or_equal_to?`\n- `earlier_than_or_equal_to?`\n\n## RSpec Matchers\n\nhuman_time also provides RSpec matchers for more understandable time comparisons in your tests.\n\nTo use these, include the following in your `spec_helper.rb` file:\n\n```ruby\nrequire 'human_time/rspec_matchers'\n```\n\nAnd then you can use the following matchers:\n\n```ruby\nolder_date = Date.parse('2016-01-01')\nnewer_date = Date.parse('2016-01-02')\n\nexpect(newer_date).to be_more_recent_than(older_date)\nexpect(newer_date).to be_newer_than(older_date)\nexpect(newer_date).to be_after(older_date)\nexpect(newer_date).to be_later_than(older_date)\nexpect(newer_date).to be_more_recent_than_or_equal_to(older_date)\nexpect(newer_date).to be_newer_than_or_equal_to(newer_date)\nexpect(newer_date).to be_later_than_or_equal_to(newer_date)\nexpect(older_date).to be_older_than(newer_date)\nexpect(older_date).to be_before(newer_date)\nexpect(older_date).to be_earlier_than(newer_date)\nexpect(older_date).to be_older_than_or_equal_to(older_date)\nexpect(older_date).to be_earlier_than_or_equal_to(older_date)\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/allenan/human_time. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [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 [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Matchers"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallenan%2Fhuman_time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallenan%2Fhuman_time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallenan%2Fhuman_time/lists"}