{"action":"opened","issue":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/3307","repository_url":"https://api.github.com/repos/crystal-lang/crystal","labels_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3307/labels{/name}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3307/comments","events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3307/events","html_url":"https://github.com/crystal-lang/crystal/issues/3307","id":176940123,"number":3307,"title":"How to handle incorrect difference between Times with different Kinds?","user":{"login":"feifanzhou","id":3407996,"avatar_url":"https://avatars.githubusercontent.com/u/3407996?v=3","gravatar_id":"","url":"https://api.github.com/users/feifanzhou","html_url":"https://github.com/feifanzhou","followers_url":"https://api.github.com/users/feifanzhou/followers","following_url":"https://api.github.com/users/feifanzhou/following{/other_user}","gists_url":"https://api.github.com/users/feifanzhou/gists{/gist_id}","starred_url":"https://api.github.com/users/feifanzhou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feifanzhou/subscriptions","organizations_url":"https://api.github.com/users/feifanzhou/orgs","repos_url":"https://api.github.com/users/feifanzhou/repos","events_url":"https://api.github.com/users/feifanzhou/events{/privacy}","received_events_url":"https://api.github.com/users/feifanzhou/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-14T15:32:15Z","updated_at":"2016-09-14T15:32:15Z","closed_at":null,"body":"Ran into this issue in Crystal 0.19.1:\r\n\r\n```\r\nit \"- computes correct span across different kinds\" do\r\n  local_now = Time.now\r\n  utc_now = Time.now.to_utc\r\n  utc_now.should be_close(local_now, Time::Span.new(0, 0, 1))\r\nend\r\n```\r\n\r\nI'd expect this test to pass. However, the difference between `utc_now` and `local_now` comes to `07:00:00.0000010` for me (I'm in PDT, currently UTC-7). As a result, this test fails:\r\n\r\n```\r\n1) Time - computes correct span across different kinds\r\n     Failure/Error: utc_now.should be_close(local_now, Time::Span.new(0, 0, 1))\r\n\r\n       expected 2016-09-14 15:26:23 UTC to be within 00:00:01 of 2016-09-14 08:26:23 -0700\r\n\r\n     # ./spec/std/time/time_spec.cr:626\r\n```\r\n\r\nI'm happy to work on this and open a PR later this week, but have two questions:\r\n\r\n1. `Time::Kind` only appears to have three options; how could I reliably write this test (specify a specific timezone) so people where UTC == local time can still run this test as intended?\r\n2. Perhaps this is \"expected\" behavior? If so, would it make sense to introduce something like `Time::AbsoluteSpan` that will represent a span between two points in time regardless of timezone?"}}
{"actor":{"display_login":"feifanzhou"}}