{"action":"created","issue":{"url":"https://api.github.com/repos/arnau/ISO8601/issues/31","labels_url":"https://api.github.com/repos/arnau/ISO8601/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/arnau/ISO8601/issues/31/comments","events_url":"https://api.github.com/repos/arnau/ISO8601/issues/31/events","html_url":"https://github.com/arnau/ISO8601/pull/31","id":116149311,"number":31,"title":"Feature #15. TimeInterval Class","user":{"login":"Angelmmiguel","id":4056725,"avatar_url":"https://avatars.githubusercontent.com/u/4056725?v=3","gravatar_id":"","url":"https://api.github.com/users/Angelmmiguel","html_url":"https://github.com/Angelmmiguel","followers_url":"https://api.github.com/users/Angelmmiguel/followers","following_url":"https://api.github.com/users/Angelmmiguel/following{/other_user}","gists_url":"https://api.github.com/users/Angelmmiguel/gists{/gist_id}","starred_url":"https://api.github.com/users/Angelmmiguel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Angelmmiguel/subscriptions","organizations_url":"https://api.github.com/users/Angelmmiguel/orgs","repos_url":"https://api.github.com/users/Angelmmiguel/repos","events_url":"https://api.github.com/users/Angelmmiguel/events{/privacy}","received_events_url":"https://api.github.com/users/Angelmmiguel/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/arnau/ISO8601/labels/feature","name":"feature","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/arnau/ISO8601/milestones/1","html_url":"https://github.com/arnau/ISO8601/milestones/0.9.0","labels_url":"https://api.github.com/repos/arnau/ISO8601/milestones/1/labels","id":1078618,"number":1,"title":"0.9.0","description":null,"creator":{"login":"arnau","id":33837,"avatar_url":"https://avatars.githubusercontent.com/u/33837?v=3","gravatar_id":"","url":"https://api.github.com/users/arnau","html_url":"https://github.com/arnau","followers_url":"https://api.github.com/users/arnau/followers","following_url":"https://api.github.com/users/arnau/following{/other_user}","gists_url":"https://api.github.com/users/arnau/gists{/gist_id}","starred_url":"https://api.github.com/users/arnau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arnau/subscriptions","organizations_url":"https://api.github.com/users/arnau/orgs","repos_url":"https://api.github.com/users/arnau/repos","events_url":"https://api.github.com/users/arnau/events{/privacy}","received_events_url":"https://api.github.com/users/arnau/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":0,"state":"open","created_at":"2015-04-22T10:05:36Z","updated_at":"2015-11-11T07:36:55Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-11-10T16:51:39Z","updated_at":"2015-11-12T06:51:30Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/arnau/ISO8601/pulls/31","html_url":"https://github.com/arnau/ISO8601/pull/31","diff_url":"https://github.com/arnau/ISO8601/pull/31.diff","patch_url":"https://github.com/arnau/ISO8601/pull/31.patch"},"body":"I created the TimeInterval class based on [ISO8601](https://en.wikipedia.org/wiki/ISO_8601#Time_intervals). The class constructor allows user to instance an object with a pattern or an ISO8601::DateTime/ISO8601::Duration objects:\r\n\r\n```ruby\r\n# ISO8601::DateTime\r\nstart_time = ISO8601::DateTime.new('2014-05-28T19:53Z')\r\nend_time = ISO8601::DateTime.new('2014-05-30T19:53Z')\r\nti = ISO8601::TimeInterval.new(start_time, end_time)\r\nti.size # => 172800.0 (Seconds)\r\n\r\n# ISO8601::Duration and ISO8601::DateTime\r\nstart_time = ISO8601::Duration.new('P1MT2H')\r\nend_time = ISO8601::DateTime.new('2014-05-30T19:53Z')\r\nti = ISO8601::TimeInterval.new(start_time, end_time)\r\nti.size # => 2635200.0 (Seconds)\r\n\r\n# Pattern\r\nti = ISO8601::TimeInterval.new('P1MT2H/2014-05-28T19:53Z')\r\nti.size # => 2635200.0\r\n```\r\n\r\nI defined multiple methods to work with TimeIntervals:\r\n\r\n* `size`, `to_f`: return the number of seconds in the interval\r\n* `pattern`: return the pattern if it's present\r\n* `start_time`, `end_time`: return the time as instance of ISO8601::DateTime\r\n* `original_start_time`, `original_end_time`: return the time as instance of ISO8601::DateTime or ISO8601::Duration\r\n* `<`, `>`, `<=`, `>=`, `==`: these methods compare the size of the intervals\r\n* `eql?`: compare two TimeIntervals objects\r\n* `include?`: check if a DateTime/TimeInterval is included in the interval\r\n* `overlap?`: check if another TimeInterval overlaps with current interval"},"comment":{"url":"https://api.github.com/repos/arnau/ISO8601/issues/comments/156017493","html_url":"https://github.com/arnau/ISO8601/pull/31#issuecomment-156017493","issue_url":"https://api.github.com/repos/arnau/ISO8601/issues/31","id":156017493,"user":{"login":"arnau","id":33837,"avatar_url":"https://avatars.githubusercontent.com/u/33837?v=3","gravatar_id":"","url":"https://api.github.com/users/arnau","html_url":"https://github.com/arnau","followers_url":"https://api.github.com/users/arnau/followers","following_url":"https://api.github.com/users/arnau/following{/other_user}","gists_url":"https://api.github.com/users/arnau/gists{/gist_id}","starred_url":"https://api.github.com/users/arnau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arnau/subscriptions","organizations_url":"https://api.github.com/users/arnau/orgs","repos_url":"https://api.github.com/users/arnau/repos","events_url":"https://api.github.com/users/arnau/events{/privacy}","received_events_url":"https://api.github.com/users/arnau/received_events","type":"User","site_admin":false},"created_at":"2015-11-12T06:51:30Z","updated_at":"2015-11-12T06:51:30Z","body":"As far as I understand a context is a datetime reference (start date) to compute the duration correctly.  Same I did with the plain `Duration` that accepts a second parameter `base`.   So for now, I would say the forth case it can be implemented as a thin wrapper over `Duration`."}}