{"action":"created","issue":{"url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/690","repository_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware","labels_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/690/labels{/name}","comments_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/690/comments","events_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/690/events","html_url":"https://github.com/nodemcu/nodemcu-firmware/issues/690","id":111746133,"number":690,"title":"tmr.time() bug – value leaps backwards","user":{"login":"smartynov","id":9915773,"avatar_url":"https://avatars.githubusercontent.com/u/9915773?v=3","gravatar_id":"","url":"https://api.github.com/users/smartynov","html_url":"https://github.com/smartynov","followers_url":"https://api.github.com/users/smartynov/followers","following_url":"https://api.github.com/users/smartynov/following{/other_user}","gists_url":"https://api.github.com/users/smartynov/gists{/gist_id}","starred_url":"https://api.github.com/users/smartynov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smartynov/subscriptions","organizations_url":"https://api.github.com/users/smartynov/orgs","repos_url":"https://api.github.com/users/smartynov/repos","events_url":"https://api.github.com/users/smartynov/events{/privacy}","received_events_url":"https://api.github.com/users/smartynov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2015-10-16T02:32:20Z","updated_at":"2016-03-12T14:56:29Z","closed_at":null,"body":"I noticed that `tmr.time()` is producing very strange behaviour: when calling it consequently it sometimes returns smaller values than on previous call. At the same time `tmr.now()` returns increasing values.\r\n\r\nHere is the minimal example:\r\n\r\n```\r\ntmr.alarm(1,100,1,function ()\r\n  tt = tmr.time()\r\n  tn = tmr.now()\r\n  if not(tt == tp) then\r\n    print(\"tt=\"..tt..\" tn=\"..tn)\r\n    tp=tt\r\n  end\r\nend)\r\n```\r\n\r\nAnd here is the output:\r\n\r\n```\r\ntt=18 tn=18099727\r\ntt=19 tn=19199832\r\ntt=20 tn=20199841\r\ntt=21 tn=21199687\r\ntt=22 tn=21899493\r\ntt=23 tn=22999399\r\ntt=24 tn=24099722\r\ntt=25 tn=24999726\r\ntt=26 tn=25999477\r\ntt=27 tn=26899470\r\ntt=28 tn=27899454\r\ntt=27 tn=27999667\r\ntt=28 tn=28099774\r\ntt=29 tn=29199720\r\n```\r\n\r\nNotice how it goes well until `tt=27` seconds, then it increases to 28 and then falls back to 27. At the same time, `tn` keeps increasing!\r\n\r\nFew more examples:\r\n```\r\ntt=47 tn=47099710\r\ntt=48 tn=48099727\r\ntt=49 tn=49199740\r\ntt=50 tn=50199697\r\ntt=51 tn=51299701\r\ntt=52 tn=51599470\r\ntt=51 tn=51799811\r\ntt=52 tn=52199728\r\ntt=53 tn=52599467\r\ntt=54 tn=53599720\r\ntt=53 tn=53799579\r\ntt=54 tn=53899808\r\ntt=55 tn=54599733\r\ntt=54 tn=54899793\r\ntt=55 tn=54999762\r\ntt=56 tn=55699505\r\ntt=55 tn=55899813\r\ntt=56 tn=56099731\r\ntt=57 tn=56799466\r\ntt=56 tn=56899844\r\n```\r\n\r\nIt is a clean test using `NodeMCU 0.9.6 build 20150704  powered by Lua 5.1.4` (integer version), code is run after a hard reset, nothing else is started in `init.lua`.\r\n"},"comment":{"url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/comments/195753161","html_url":"https://github.com/nodemcu/nodemcu-firmware/issues/690#issuecomment-195753161","issue_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/690","id":195753161,"user":{"login":"innesm","id":133220,"avatar_url":"https://avatars.githubusercontent.com/u/133220?v=3","gravatar_id":"","url":"https://api.github.com/users/innesm","html_url":"https://github.com/innesm","followers_url":"https://api.github.com/users/innesm/followers","following_url":"https://api.github.com/users/innesm/following{/other_user}","gists_url":"https://api.github.com/users/innesm/gists{/gist_id}","starred_url":"https://api.github.com/users/innesm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/innesm/subscriptions","organizations_url":"https://api.github.com/users/innesm/orgs","repos_url":"https://api.github.com/users/innesm/repos","events_url":"https://api.github.com/users/innesm/events{/privacy}","received_events_url":"https://api.github.com/users/innesm/received_events","type":"User","site_admin":false},"created_at":"2016-03-12T14:56:29Z","updated_at":"2016-03-12T14:56:29Z","body":"It might be a good idea to update the nodemcu documentation to say \"don't use tmr.time(), it doesn't work\"."}}