{"action":"created","issue":{"url":"https://api.github.com/repos/ocaml-community/calendar/issues/13","repository_url":"https://api.github.com/repos/ocaml-community/calendar","labels_url":"https://api.github.com/repos/ocaml-community/calendar/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/ocaml-community/calendar/issues/13/comments","events_url":"https://api.github.com/repos/ocaml-community/calendar/issues/13/events","html_url":"https://github.com/ocaml-community/calendar/issues/13","id":362829548,"node_id":"MDU6SXNzdWUzNjI4Mjk1NDg=","number":13,"title":"Off-by-one in precise_sub","user":{"login":"loxs","id":162763,"node_id":"MDQ6VXNlcjE2Mjc2Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/162763?v=4","gravatar_id":"","url":"https://api.github.com/users/loxs","html_url":"https://github.com/loxs","followers_url":"https://api.github.com/users/loxs/followers","following_url":"https://api.github.com/users/loxs/following{/other_user}","gists_url":"https://api.github.com/users/loxs/gists{/gist_id}","starred_url":"https://api.github.com/users/loxs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loxs/subscriptions","organizations_url":"https://api.github.com/users/loxs/orgs","repos_url":"https://api.github.com/users/loxs/repos","events_url":"https://api.github.com/users/loxs/events{/privacy}","received_events_url":"https://api.github.com/users/loxs/received_events","type":"User","site_admin":false},"labels":[{"id":1064742218,"node_id":"MDU6TGFiZWwxMDY0NzQyMjE4","url":"https://api.github.com/repos/ocaml-community/calendar/labels/bug","name":"bug","color":"d73a4a","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/ocaml-community/calendar/milestones/1","html_url":"https://github.com/ocaml-community/calendar/milestone/1","labels_url":"https://api.github.com/repos/ocaml-community/calendar/milestones/1/labels","id":3679435,"node_id":"MDk6TWlsZXN0b25lMzY3OTQzNQ==","number":1,"title":"3.0","description":"","creator":{"login":"loxs","id":162763,"node_id":"MDQ6VXNlcjE2Mjc2Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/162763?v=4","gravatar_id":"","url":"https://api.github.com/users/loxs","html_url":"https://github.com/loxs","followers_url":"https://api.github.com/users/loxs/followers","following_url":"https://api.github.com/users/loxs/following{/other_user}","gists_url":"https://api.github.com/users/loxs/gists{/gist_id}","starred_url":"https://api.github.com/users/loxs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loxs/subscriptions","organizations_url":"https://api.github.com/users/loxs/orgs","repos_url":"https://api.github.com/users/loxs/repos","events_url":"https://api.github.com/users/loxs/events{/privacy}","received_events_url":"https://api.github.com/users/loxs/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":1,"state":"open","created_at":"2018-09-22T05:40:26Z","updated_at":"2018-09-29T12:02:14Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2018-09-22T05:55:50Z","updated_at":"2018-09-29T13:34:21Z","closed_at":null,"author_association":"COLLABORATOR","body":"**Originally reported [here](https://forge.ocamlcore.org/tracker/index.php?func=detail&aid=1748&group_id=83&atid=415) by Stephen Dolan**\r\n\r\nI expected that if I use CalendarLib.Calendar.Precise.precise_sub to compute the difference between two dates, then I could add this difference to the earlier and get the later.\r\n\r\nHowever, if I attempt this on [2025-03-31 17:53:04; 2026-07-19 12:15:23], then the result of add is 2026-07-20 12:15:23, not 2026-07-19 12:15:23."},"comment":{"url":"https://api.github.com/repos/ocaml-community/calendar/issues/comments/425645699","html_url":"https://github.com/ocaml-community/calendar/issues/13#issuecomment-425645699","issue_url":"https://api.github.com/repos/ocaml-community/calendar/issues/13","id":425645699,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTY0NTY5OQ==","user":{"login":"loxs","id":162763,"node_id":"MDQ6VXNlcjE2Mjc2Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/162763?v=4","gravatar_id":"","url":"https://api.github.com/users/loxs","html_url":"https://github.com/loxs","followers_url":"https://api.github.com/users/loxs/followers","following_url":"https://api.github.com/users/loxs/following{/other_user}","gists_url":"https://api.github.com/users/loxs/gists{/gist_id}","starred_url":"https://api.github.com/users/loxs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loxs/subscriptions","organizations_url":"https://api.github.com/users/loxs/orgs","repos_url":"https://api.github.com/users/loxs/repos","events_url":"https://api.github.com/users/loxs/events{/privacy}","received_events_url":"https://api.github.com/users/loxs/received_events","type":"User","site_admin":false},"created_at":"2018-09-29T13:34:21Z","updated_at":"2018-09-29T13:34:21Z","author_association":"COLLABORATOR","body":"I was wrong, doesn't have anything to do with leap years:\r\n\r\n```\r\nlet test_precise_sub start ending =\r\n    Date.precise_sub ending start |> Date.add start |> Printer.Date.to_string\r\n```\r\nFor this case it only happens for dates between 2025-07-10 and 2025-07-30:\r\n\r\n```\r\nutop # test_precise_sub (Date.make 2025 3 31) (Date.make 2026 7 9);;\r\n- : string = \"2026-07-09\"\r\nutop # test_precise_sub (Date.make 2025 3 31) (Date.make 2026 7 10);;\r\n- : string = \"2026-07-11\"\r\nutop # test_precise_sub (Date.make 2025 3 31) (Date.make 2026 7 30);;\r\n- : string = \"2026-07-31\"\r\nutop # test_precise_sub (Date.make 2025 3 31) (Date.make 2026 7 31);;\r\n- : string = \"2026-07-31\"\r\n```\r\n\r\nutop # test_precise_sub (Date.make 2018 5 31) (Date.make 2018 7 2);;\r\n- : string = \"2018-07-03\"\r\n\r\nSeems to happen when jumping from **the last day** of an odd numbered month into July but not for all days of July:\r\n\r\n\r\nutop # test_precise_sub (Date.make 2018 3 31) (Date.make 2018 7 20);;\r\n- : string = \"2018-07-21\"\r\nutop # test_precise_sub (Date.make 2018 3 31) (Date.make 2018 7 6);;\r\n- : string = \"2018-07-07\"\r\nutop # test_precise_sub (Date.make 2018 3 31) (Date.make 2018 7 2);;\r\n- : string = \"2018-07-02\"\r\n\r\nutop # test_precise_sub (Date.make 2018 3 31) (Date.make 2018 7 20);;\r\n- : string = \"2018-07-21\"\r\nutop # test_precise_sub (Date.make 2018 3 31) (Date.make 2018 7 6);;\r\n- : string = \"2018-07-07\"\r\nutop # test_precise_sub (Date.make 2018 3 31) (Date.make 2018 7 2);;\r\n- : string = \"2018-07-02\"\r\n\r\nSo far I haven't been able to reproduce it with anything other than July"}}
{"actor":{"display_login":"loxs"}}