Twitter | Search | |
vixentael ๐Ÿ‘ฉโ€๐Ÿ’ป 21 May 19
If you want to measure time difference between two events you shouldn't rely on current time, because user can change clock back. You could use monotonic clock or boot timer instead. F.e. this code piece allows your app to lock some features after X secs.
Reply Retweet Like
๐Ÿ††il ๐Ÿ†‚hipley
Ok so Iโ€™m not ๐˜ซ๐˜ถ๐˜ด๐˜ต being snide I rewrote this in Swift. Also I made it return a ๐—ง๐—ถ๐—บ๐—ฒ๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐˜ƒ๐—ฎ๐—น because the ๐——๐—ฎ๐˜๐—ฒs it returned are, like meaningless dates in 1970 and that didnโ€™t make sense to me. Also I think it could be valid for bootTime seconds to be 0?
Reply Retweet Like More
๐Ÿ††il ๐Ÿ†‚hipley 22 May 19
Replying to @vixentael @jckarter
Actually why not just use ProcessInfo.processInfo.systemUptime?
Reply Retweet Like
vixentael ๐Ÿ‘ฉโ€๐Ÿ’ป Oct 27
Replying to @wilshipley @jckarter
Half a year and some experiments later, and yes, now I'm sure that it's totally valid to have 0 seconds of bootTime :)) Also, that you for your swift example, it was very useful on some point.
Reply Retweet Like