Repository navigation
doc: are os.uptime() returned type and remark correct? #12291
Description
Activity
Output on macOS (Sierra):
> os.uptime()
245758
> process.uptime()
281.972Output on Ubuntu 16.04:
> os.uptime()
174
> process.uptime()
9.451So it seems this is wrong only for Windows. What should be fixed — doc or Windows implementation?
If Windows implementation should be fixed, is it worth to land it in 8.0 as this is semver-major (despite of the doc though)?
cc @nodejs/platform-windows
The documentation is wrong-ish. uv_uptime() returns (in an out param) a double but the UNIX implementations of that function don't currently bother to mix in the sub-second fraction. That could change in the future though, if someone requests it.
So the doc should describe OS-dependent behavior here? If so, can anybody edit it, as I am not good at writing long English text properly? Or I can open a PR with a proposed wording.
How about this?
Note: the return value includes fractions of a second on some platforms. Use
Math.floor()to get whole seconds.
Feel free to steal and PR.
Maybe worth changing on some platforms to on Windows if it's Windows specific.
I've combined two propositions in #12294
Currently, both
os.uptime()andprocess.uptime()return number with fractional seconds on Windows:However, their docs are different here:
https://github.com/nodejs/node/blame/7a5d07c7fbd43f3645d7f707fd6a98f2a251bdbd/doc/api/os.md#L372-L384
https://github.com/nodejs/node/blame/47f8f7462fb198aa27ede602c43786bdbfda37a2/doc/api/process.md#L1662-L1671
Are
os.uptime()returned typeintegerand*Note*outdated or just OS-dependent?