{"action":"created","issue":{"url":"https://api.github.com/repos/uniplaces/carbon/issues/48","repository_url":"https://api.github.com/repos/uniplaces/carbon","labels_url":"https://api.github.com/repos/uniplaces/carbon/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/uniplaces/carbon/issues/48/comments","events_url":"https://api.github.com/repos/uniplaces/carbon/issues/48/events","html_url":"https://github.com/uniplaces/carbon/issues/48","id":386780881,"node_id":"MDU6SXNzdWUzODY3ODA4ODE=","number":48,"title":"The timestamp will change after calling the `carbon.CreateFromTimestampUTC()` method","user":{"login":"BigKuCha","id":5095944,"node_id":"MDQ6VXNlcjUwOTU5NDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/5095944?v=4","gravatar_id":"","url":"https://api.github.com/users/BigKuCha","html_url":"https://github.com/BigKuCha","followers_url":"https://api.github.com/users/BigKuCha/followers","following_url":"https://api.github.com/users/BigKuCha/following{/other_user}","gists_url":"https://api.github.com/users/BigKuCha/gists{/gist_id}","starred_url":"https://api.github.com/users/BigKuCha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BigKuCha/subscriptions","organizations_url":"https://api.github.com/users/BigKuCha/orgs","repos_url":"https://api.github.com/users/BigKuCha/repos","events_url":"https://api.github.com/users/BigKuCha/events{/privacy}","received_events_url":"https://api.github.com/users/BigKuCha/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-12-03T11:45:31Z","updated_at":"2018-12-05T00:49:37Z","closed_at":null,"author_association":"NONE","body":"```\r\nunix := time.Now().UTC().Unix()\r\nutcTime, _ := carbon.CreateFromTimestampUTC(unix)\r\nif unix != utcTime.Unix() {\r\n    fmt.Println(unix, utcTime.Unix())\r\n}\r\n```\r\n\r\nWhy are `unix` and `utcTime.Unix()` not equal?\r\nI got `1543837131` `1543865931`"},"comment":{"url":"https://api.github.com/repos/uniplaces/carbon/issues/comments/444315721","html_url":"https://github.com/uniplaces/carbon/issues/48#issuecomment-444315721","issue_url":"https://api.github.com/repos/uniplaces/carbon/issues/48","id":444315721,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NDMxNTcyMQ==","user":{"login":"dcb9","id":3984347,"node_id":"MDQ6VXNlcjM5ODQzNDc=","avatar_url":"https://avatars1.githubusercontent.com/u/3984347?v=4","gravatar_id":"","url":"https://api.github.com/users/dcb9","html_url":"https://github.com/dcb9","followers_url":"https://api.github.com/users/dcb9/followers","following_url":"https://api.github.com/users/dcb9/following{/other_user}","gists_url":"https://api.github.com/users/dcb9/gists{/gist_id}","starred_url":"https://api.github.com/users/dcb9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcb9/subscriptions","organizations_url":"https://api.github.com/users/dcb9/orgs","repos_url":"https://api.github.com/users/dcb9/repos","events_url":"https://api.github.com/users/dcb9/events{/privacy}","received_events_url":"https://api.github.com/users/dcb9/received_events","type":"User","site_admin":false},"created_at":"2018-12-05T00:49:37Z","updated_at":"2018-12-05T00:49:37Z","author_association":"NONE","body":"@hfcorreia the result is as same as before. it will pass if i set my local timezone to **UTC+0**, so i guess that your local timezone is UTC+0.\r\n\r\nThe function, `carbon.CreateFromTimestampUTC() func`, should not depend on the OS local timezone isn't it? It is necessary to test it on different timezone.\r\n\r\n```\r\n➜  carbon git:(master) ✗ date +\"%Z %z\" ; go test -run TestSetUnix ./ -v\r\nUTC +0000\r\n=== RUN   TestSetUnix\r\n--- PASS: TestSetUnix (0.00s)\r\nPASS\r\nok  \tgithub.com/uniplaces/carbon\t0.015s\r\n➜  carbon git:(master) ✗ date +\"%Z %z\" ; go test -run TestSetUnix ./ -v\r\nPST -0800\r\n=== RUN   TestSetUnix\r\n--- FAIL: TestSetUnix (0.00s)\r\n        Error Trace:    carbon_test.go:2754\r\n        Error:\t\tNot equal: 1543970164 (expected)\r\n        \t        != 1543941364 (actual)\r\n\r\nFAIL\r\nFAIL\tgithub.com/uniplaces/carbon\t0.026s\r\n```\r\n\r\nafter i did this no matter what my system timezone is, the test will never fail.\r\n> Maybe below is a correct implementation:\r\n> \r\n> ```diff\r\n> filename: carbon.go\r\n> \r\n> // SetTimestamp sets the current time given a timestamp\r\n> func (c *Carbon) SetTimestamp(sec int64) {\r\n> -   t := time.Unix(sec, 0)\r\n> +   t := time.Unix(sec, 0).In(c.Location())\r\n>     c.Time = time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), c.Location())\r\n> }\r\n> ```\r\n\r\n\r\n"}}
{"actor":{"display_login":"dcb9"}}