When trying to compile the following example:
std::chrono::sys_time<std::chrono::microseconds> timestamp; std::stringstream ss = foo(); ss >> std::chrono::parse("%Y-%m-%d %T", timestamp); I get:
error: ‘parse’ is not a member of ‘std::chrono’ 15 | ss >> std::chrono::parse("%Y-%m-%d %T", timestamp); | ^~~~~ I was not expecting this, as I'm using the latest g++ I could find.
More info:
$ g++-11 --version g++-11 (Ubuntu 11.1.0-1ubuntu1~18.04.1) 11.1.0 $ g++-11 -v Using built-in specs. COLLECT_GCC=g++-11 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: (...) Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.1.0 (Ubuntu 11.1.0-1ubuntu1~18.04.1) I'm compiling with:
g++-11 -std=c++2a -o test time.cc Is this just not supported in g++-11.1.0?
sscanfwriting into astruct tmfor all fields except forts_sec, which I set to zero. Then I usetimegmto get the timestamp in seconds, and add things up with a float that I parse in scanf for number of seconds (taking in to account the units ofc).