{"action":"created","issue":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/3609","labels_url":"https://api.github.com/repos/nim-lang/Nim/issues/3609/labels{/name}","comments_url":"https://api.github.com/repos/nim-lang/Nim/issues/3609/comments","events_url":"https://api.github.com/repos/nim-lang/Nim/issues/3609/events","html_url":"https://github.com/nim-lang/Nim/issues/3609","id":119655622,"number":3609,"title":"Additions to times","user":{"login":"jlp765","id":5141524,"avatar_url":"https://avatars.githubusercontent.com/u/5141524?v=3","gravatar_id":"","url":"https://api.github.com/users/jlp765","html_url":"https://github.com/jlp765","followers_url":"https://api.github.com/users/jlp765/followers","following_url":"https://api.github.com/users/jlp765/following{/other_user}","gists_url":"https://api.github.com/users/jlp765/gists{/gist_id}","starred_url":"https://api.github.com/users/jlp765/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlp765/subscriptions","organizations_url":"https://api.github.com/users/jlp765/orgs","repos_url":"https://api.github.com/users/jlp765/repos","events_url":"https://api.github.com/users/jlp765/events{/privacy}","received_events_url":"https://api.github.com/users/jlp765/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-01T06:53:57Z","updated_at":"2015-12-01T23:52:49Z","closed_at":null,"body":"This is an RFC on some `times` related procs.\r\n\r\nI made some helper procs to work with the `TimeInterval` type\r\n\r\n```\r\nproc tiMSecs*(ms: int): TimeInterval {.inline.} = initInterval(ms)\r\n  ## TimeInterval of `ms` milliseconds\r\nproc tiSecs*(s: int): TimeInterval {.inline.} = initInterval(0,s)\r\n  ## TimeInterval of `s` seconds\r\nproc tiMins*(m: int): TimeInterval {.inline.} = initInterval(0,0,m)\r\n  ## TimeInterval of `m` minutes\r\nproc tiHrs*(h: int): TimeInterval {.inline.} = initInterval(0,0,0,h)\r\n  ## TimeInterval of `h` hours\r\nproc tiDays*(d: int): TimeInterval {.inline.} = initInterval(0,0,0,0,d)\r\n  ## TimeInterval of `d` days\r\nproc tiMonths*(m: int): TimeInterval {.inline.} = initInterval(0,0,0,0,0,m)\r\n  ## TimeInterval of `m` months\r\nproc tiYrs*(y: int): TimeInterval {.inline.} = initInterval(0,0,0,0,0,0,y)\r\n  ## TimeInterval of `y` years\r\n\r\nproc `+=`*(t: var Time, ti: TimeInterval) =\r\n  ## adds the interval `ti` to Time `t`\r\n  ## by converting to localTime, adding the interval, and converting back\r\n  t = timeInfoToTime(getLocalTime(t) + ti)\r\n    \r\nproc `+`*(t: Time, ti: TimeInterval): Time =\r\n  ## adds the interval `ti` to Time `t`\r\n  ## by converting to localTime, adding the interval, and converting back\r\n  result = timeInfoToTime(getLocalTime(t) + ti)\r\n  \r\nproc `-=`*(t: var Time, ti: TimeInterval) =\r\n  ## adds the interval `ti` to Time `t`\r\n  ## by converting to localTime, adding the interval, and converting back\r\n  t = timeInfoToTime(getLocalTime(t) - ti)\r\n  \r\nproc `-`*(t: Time, ti: TimeInterval): Time =\r\n  ## adds the interval `ti` to Time `t`\r\n  ## by converting to localTime, adding the interval, and converting back\r\n  result = timeInfoToTime(getLocalTime(t) - ti)\r\n  \r\n```\r\n\r\nwhich allows\r\n```\r\nvar\r\n  t = getTime()\r\necho getLocalTime(t), \"\\n\", getLocalTime(t + tiSecs(-3))\r\nt += tiHrs(2)\r\necho getLocalTime(t), \"\\n\", getLocalTime(t) - tiSecs(3)\r\nt -= tiHrs(2)\r\necho getLocalTime(t)\r\n\r\nvar ti = getLocalTime(t)\r\necho ti-tiSecs(3)+tiYrs(1)\r\n```\r\n\r\nShould this be a PR and get added to the time module?"},"comment":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/comments/161134744","html_url":"https://github.com/nim-lang/Nim/issues/3609#issuecomment-161134744","issue_url":"https://api.github.com/repos/nim-lang/Nim/issues/3609","id":161134744,"user":{"login":"kirbyfan64","id":1690697,"avatar_url":"https://avatars.githubusercontent.com/u/1690697?v=3","gravatar_id":"","url":"https://api.github.com/users/kirbyfan64","html_url":"https://github.com/kirbyfan64","followers_url":"https://api.github.com/users/kirbyfan64/followers","following_url":"https://api.github.com/users/kirbyfan64/following{/other_user}","gists_url":"https://api.github.com/users/kirbyfan64/gists{/gist_id}","starred_url":"https://api.github.com/users/kirbyfan64/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kirbyfan64/subscriptions","organizations_url":"https://api.github.com/users/kirbyfan64/orgs","repos_url":"https://api.github.com/users/kirbyfan64/repos","events_url":"https://api.github.com/users/kirbyfan64/events{/privacy}","received_events_url":"https://api.github.com/users/kirbyfan64/received_events","type":"User","site_admin":false},"created_at":"2015-12-01T23:52:49Z","updated_at":"2015-12-01T23:52:49Z","body":"```\r\nsecondsInterval\r\nmillisecondsInterval # or msInterval\r\netc.\r\n```"}}