File: test-chrono_from_stream.cpp

package info (click to toggle)
libzeem 2.1.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 808 kB
  • sloc: cpp: 13,810; xml: 49; makefile: 15; sh: 11
file content (17 lines) | stat: -rw-r--r-- 358 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <chrono>

int main()
{
	using namespace std::chrono_literals;

	int result = 0;

	std::stringstream is{ "01-01-2025T00:00:01" };
	std::chrono::time_point<std::chrono::system_clock> t{};
	std::chrono::from_stream(is, "%d-%m-%YT%T", t);

	if (is.bad() or is.fail() or t != std::chrono::sys_days{ 2025y / 1 / 1 } + 1s)
		result = -1;

	return result;
}