Skip to main content
7 votes
4 answers
346 views

After running this program (compiled with MSVC compiler 19.50.35723 with option /std:c++23preview) #include <print> #include <chrono> #include <string> int main() { using ...
Angle.Bracket's user avatar
2 votes
2 answers
183 views

If I do: #include <chrono> #include "./date/date.h" #include "./date/tz.h" using UtcTime = std::chrono::time_point<std::chrono::system_clock>; UtcTime xParseRfc822(...
Martin Perry's user avatar
  • 9,665
4 votes
3 answers
265 views

Consider this example: #include <atomic> #include <chrono> #include <thread> uint64_t timestamp() { auto now = std::chrono::steady_clock::now().time_since_epoch(); return ...
xmh0511's user avatar
  • 7,763
9 votes
2 answers
739 views

C++, using <chrono>, I would like to get a value formatted as <seconds>.<milliseconds>. I am using system_clock and get the current seconds as: auto secs = duration_cast<seconds&...
Ender's user avatar
  • 1,922
1 vote
1 answer
127 views

I've come across a strange issue related to Howard Hinnant's date.h library that causes all of <chrono> to break, at least according to VS. It appears to be related to using date/date.h in a ...
angelicelyria's user avatar
3 votes
3 answers
188 views

I'm generating a string representation of the current time in the local time zone for my logging system. I have an "old" version, and I wanted to see if I could improve its performance. Old ...
Carsten Kjaer's user avatar
6 votes
1 answer
226 views

RFC-9557 allows tagging a time stamp with time zone information such as: 2022-07-08T00:14:07+02:00[Europe/Paris] I would like to be able to parse this into a C++20 chrono data structure and format it ...
Howard Hinnant's user avatar
0 votes
1 answer
292 views

C++20 introduces std::chrono::from_stream() to parse date/time from a string and store it in a std::chrono::time_point. For example: std::stringstream ss("2018-12-09T00:00:00+0130"); std::...
user149408's user avatar
  • 6,299
3 votes
1 answer
249 views

I am using gcc-13.3 with c++23 enabled. I have the following code which uses std::format to format a std::chrono::year_month_day to a string: #include <chrono> #include <format> #include &...
Steve Lorimer's user avatar
7 votes
1 answer
118 views

In this answer there is a user-written time zone called OffsetZone that can be put into a zoned_time. #include <chrono> class OffsetZone { std::chrono::minutes offset_; public: ...
Howard Hinnant's user avatar
6 votes
1 answer
104 views

I have a UTC offset that is not known until run-time, and is not necessarily an integral number of hours. The IANA time zone database isn't a good match for this. What is the simplest user-written ...
Howard Hinnant's user avatar
30 votes
1 answer
1k views

There are lots of Stack Overflow Q&A's solving this problem in other languages, but not so much in C++. How do I find the Nth weekday of the month using <chrono>? For example, what is the ...
Howard Hinnant's user avatar
8 votes
1 answer
147 views

I would like to convert back and forth between the Julian calendar and <chrono>'s civil calendar. What is the best way to do that?
Howard Hinnant's user avatar
11 votes
1 answer
758 views

How do I write: auto // either sys_days or year_month_day easter(std::chrono::year y); I'm aware of the SO question Function to return date of Easter for the given year but I would like to know how ...
Howard Hinnant's user avatar
22 votes
1 answer
1k views

Given a year, month and day, how do I find the next weekday on or after that date? For example, If I have 2025-04-28, how can I find the Friday following 2025-04-28, which is 2025-05-02? What about ...
Howard Hinnant's user avatar

15 30 50 per page
1
2 3 4 5
73