1

i have a core file for c++ code which shows the value of std::chrono::steady_clock::now() as follows in gdb:

__d = {__r = 783605893786420}

how do i convert it to UTC ?

learner
  • 93
  • 8
  • Do you want to convert it to UTC in your program or do you want it do be displayed as a utc time in the debugging panel of vscode? – Wutz May 18 '19 at 01:09
  • i want to convert "783605893786420" to actual utc value (in gdb or any other way). – learner May 18 '19 at 01:29

1 Answers1

2

The units of steady_clock on your platform is nanoseconds.

783605893786420ns is the amount of time since the steady_clock epoch.

783605893786420ns is the same amount of time as 9 days, 1 hour, 40 minutes, and 5.893786420 seconds.

So for this clock, the epoch was 9 days, 1 hour, 40 minutes, and 5.893786420 seconds prior to when steady_clock::now() was called.

The only way you can convert this to UTC is if you know the relationship between UTC and the time 9 days, 1 hour, 40 minutes, and 5.893786420 seconds prior to when this call was made. Most likely, this would be the last time your machine booted up. If by any chance you know what UTC time your machine was booted up, you can add 9 days, 1 hour, 40 minutes, and 5.893786420 seconds to that time to convert 783605893786420 to UTC.

In the future, if you want to discover UTC times, use system_clock instead.

Howard Hinnant
  • 206,506
  • 52
  • 449
  • 577