c++-chrono Questions
2
Solved
I've got an algorithm I've used for years to emulate a real-time clock in a non-real-time environment. It's always worked exceptionally well until used on Ubuntu 24.04 in WSL2 in Windows 11. The lo...
Millihenry asked 21/9, 2024 at 19:13
2
Solved
unsigned int Tick = GetTickCount();
This code is running only on Windows, but I want to use the C++ Standard library so it can run elsewhere.
I searched std::chrono, but I can't find a function ...
Diminution asked 25/7, 2014 at 13:57
6
Solved
How to convert std::chrono::time_point to string?
For example: "201601161125".
Hardandfast asked 18/1, 2016 at 14:28
1
Solved
I was running a C++ program that provides a service, and noticed that it was taking 100% of a CPU even when serving no requests. I narrowed the problem down to a while loop which calls std::sleep_f...
Alligator asked 10/1, 2024 at 16:12
9
Solved
I wrote a solution for Windows using MSVC2015 where the follow code converts the std::filesystem::last_write_time() result to time_t:
time_t ftime = std::file_time_type::clock::to_time_t(fs::last_w...
Madlin asked 4/4, 2020 at 15:25
1
Solved
The <chrono> library allows dates to silently fall into a state of !ok(). For example:
#include <chrono>
#include <iostream>
int
main()
{
using namespace std;
using namespace c...
Elisaelisabet asked 14/11, 2023 at 3:42
2
Solved
I am trying to format a std::chrono::duration object to the format HH:MM::SS, e.g. 16:42:02 being the hours (16), the minutes (42), and the seconds (2).
the library fmt offers useful formatting spe...
Glittery asked 10/11, 2023 at 17:13
1
Solved
In MSVC chrono implementation I see the following code
_EXPORT_STD template <int = 0>
_NODISCARD constexpr year_month operator+(const year_month& _Left, const months& _Right) noexcep...
Wheelwright asked 26/9, 2023 at 7:19
3
Solved
I have simple function:
void foo(std::chrono::milliseconds ms) {
std::cout << ms.count() << " milliseconds" << std::endl;
}
And next I'm calling them like this:
int ma...
Lyndel asked 31/8, 2023 at 21:12
9
Solved
I have been upgrading some old code and have been trying to update to c++11 where possible. The following code is how I used to display the time and date in my program
#include <iostream>
#i...
Acatalectic asked 20/6, 2013 at 20:23
2
Solved
I need iterate all months in a code:
for (auto m = std::chrono::January; m <= std::chrono::December; m++)
std::cout << std::format(std::locale { "pt_BR.UTF-8" }, "{:L%B}\n&...
Gynaecology asked 17/7, 2023 at 15:19
6
Solved
I'm using c++11 <chrono> and have a number of seconds represented as a double. I want to use c++11 to sleep for this duration, but I cannot fathom how to convert it to a std::chrono::duration...
Hemstitch asked 27/7, 2013 at 15:56
3
Solved
If I have a time_point for an arbitrary clock (say high_resolution_clock::time_point), is there a way to convert it to a time_point for another arbitrary clock (say system_clock::time_point)?
I kno...
Mellophone asked 9/2, 2016 at 1:10
1
Solved
I'm just trying to print the current weekday (local time) using C++20 std::chrono.
Seems easy enough (one, two, three):
#include <chrono>
#include <iostream>
int main() {
using namesp...
Savitt asked 27/6, 2023 at 3:22
11
Solved
How can I find out what type the compiler deduced when using the auto keyword?
Example 1: Simpler
auto tickTime = 0.001;
Was this deduced as a float or a double?
Example 2: More complex (and m...
Godbeare asked 8/8, 2016 at 2:39
1
Solved
What is the correct way to format seconds in c++20 (using std::format) without also showing fractional digits?
This code:
#include <chrono>
#include <format>
#include <iostream>
...
Handsaw asked 26/4, 2023 at 0:34
1
Solved
std::chrono::parse and std::chrono::from_stream allows us to parse many different date/time formats.
But I recently got a string like this:
2022-07-10 22:00 GMT+2 - and I'm not sure what format sho...
Specie asked 14/4, 2023 at 8:0
9
Solved
I've created a time point, but I have been struggling to print it to the terminal.
#include <iostream>
#include <chrono>
int main(){
//set time_point to current time
std::chrono::t...
Filomena asked 3/4, 2013 at 0:54
1
Solved
I'm able to display the current time using C++ fmt library using std::chrono::system_clock and std::chrono::high_resolution_clock but unable to display time using std::chrono::steady_clock.
Here is...
Botryoidal asked 25/2, 2023 at 11:18
2
Solved
Let's assume we have a simple function that takes a std::chrono::time_point and returns a string using a given formatting string. Like so:
std::string DateTimeToString(std::chrono::sys_time, const ...
Gerous asked 21/7, 2021 at 11:40
3
Solved
Let's have using duration = std::chrono::steady_clock::duration. I would like to convert duration to double in seconds with maximal precision elegantly.
I have found the reverse way, but it didn't ...
Energetics asked 17/8, 2019 at 17:31
4
Solved
I have a starting timepoint in milliseconds like so:
using namespace std::chrono;
typedef time_point<system_clock, milliseconds> MyTimePoint;
MyTimePoint startTimePoint = time_point_cast<...
Christabella asked 27/9, 2015 at 19:4
4
Is the epoch of steady_clock relative to when the operating system starts? or to the process itself?
Using boost::chrono::steady_clock or std::chrono::steady_clock is suppose to guarantee that physical time is always monotonic and is not affected by date time changes in the system. Here is my ques...
Announcement asked 17/6, 2015 at 5:29
2
Solved
What is the best/easiest way to deal with Julian days in C++? I want to be able to convert between Julian days and Gregorian dates. I have C++11 and C++14. Can the <chrono> library help with ...
Campanulate asked 27/11, 2015 at 20:31
1
Solved
An earlier version of the documentation for the C++ {fmt} libary said, about the "chrono format specifiers":
Specifiers that have a calendaric component such as 'd' (the day of month) ar...
Agbogla asked 9/9, 2022 at 3:31
1 Next >
© 2022 - 2025 — McMap. All rights reserved.