Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: are os.uptime() returned type and remark correct? #12291

Closed
vsemozhetbyt opened this issue Apr 9, 2017 · 8 comments
Closed

doc: are os.uptime() returned type and remark correct? #12291

vsemozhetbyt opened this issue Apr 9, 2017 · 8 comments
Labels
doc Issues and PRs related to the documentations. os Issues and PRs related to the os subsystem.

Comments

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Apr 9, 2017

  • Version: 8.0.0-rc.0
  • Platform: Windows 7 x64
  • Subsystem: doc, os

Currently, both os.uptime() and process.uptime() return number with fractional seconds on Windows:

> os.uptime()
34298.2171316
> process.uptime()
20.648

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 type integer and *Note* outdated or just OS-dependent?

@vsemozhetbyt vsemozhetbyt added doc Issues and PRs related to the documentations. os Issues and PRs related to the os subsystem. labels Apr 9, 2017
@vsemozhetbyt vsemozhetbyt changed the title doc: are os.uptime() retutned type and remark correct? doc: are os.uptime() returned type and remark correct? Apr 9, 2017
@gibfahn
Copy link
Member

gibfahn commented Apr 9, 2017

Output on macOS (Sierra):

> os.uptime()
245758
> process.uptime()
281.972

Output on Ubuntu 16.04:

> os.uptime()
174
> process.uptime()
9.451

@vsemozhetbyt
Copy link
Contributor Author

So it seems this is wrong only for Windows. What should be fixed — doc or Windows implementation?

@vsemozhetbyt vsemozhetbyt added the windows Issues and PRs related to the Windows platform. label Apr 9, 2017
@vsemozhetbyt
Copy link
Contributor Author

vsemozhetbyt commented Apr 9, 2017

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

@bnoordhuis
Copy link
Member

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.

@vsemozhetbyt
Copy link
Contributor Author

vsemozhetbyt commented Apr 9, 2017

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.

@vsemozhetbyt vsemozhetbyt removed the windows Issues and PRs related to the Windows platform. label Apr 9, 2017
@bnoordhuis
Copy link
Member

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.

@gibfahn
Copy link
Member

gibfahn commented Apr 9, 2017

Maybe worth changing on some platforms to on Windows if it's Windows specific.

@vsemozhetbyt
Copy link
Contributor Author

I've combined two propositions in #12294

evanlucas pushed a commit that referenced this issue Apr 25, 2017
PR-URL: #12294
Fixes: #12291
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
evanlucas pushed a commit that referenced this issue May 1, 2017
PR-URL: #12294
Fixes: #12291
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
evanlucas pushed a commit that referenced this issue May 2, 2017
PR-URL: #12294
Fixes: #12291
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
gibfahn pushed a commit that referenced this issue Jun 18, 2017
PR-URL: #12294
Fixes: #12291
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
gibfahn pushed a commit that referenced this issue Jun 20, 2017
PR-URL: #12294
Fixes: #12291
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this issue Jul 11, 2017
PR-URL: #12294
Fixes: #12291
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. os Issues and PRs related to the os subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants