Skip to content

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

Description

@vsemozhetbyt
  • 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?

Activity

added
docIssues and PRs related to Node.js documentation.
osIssues and PRs related to the os subsystem.
on Apr 9, 2017
changed the title [-]doc: are `os.uptime()` retutned type and remark correct?[/-] [+]doc: are `os.uptime()` returned type and remark correct?[/+] on Apr 9, 2017

gibfahn commented on Apr 9, 2017

@gibfahn
Member

Output on macOS (Sierra):

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

Output on Ubuntu 16.04:

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

vsemozhetbyt commented on Apr 9, 2017

@vsemozhetbyt
ContributorAuthor

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

added
windowsIssues and PRs related to the Windows platform.
on Apr 9, 2017

vsemozhetbyt commented on Apr 9, 2017

@vsemozhetbyt
ContributorAuthor

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 commented on Apr 9, 2017

@bnoordhuis
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 commented on Apr 9, 2017

@vsemozhetbyt
ContributorAuthor

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.

removed
windowsIssues and PRs related to the Windows platform.
on Apr 9, 2017

bnoordhuis commented on Apr 9, 2017

@bnoordhuis
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 commented on Apr 9, 2017

@gibfahn
Member

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

vsemozhetbyt commented on Apr 9, 2017

@vsemozhetbyt
ContributorAuthor

I've combined two propositions in #12294

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to Node.js documentation.osIssues and PRs related to the os subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions