69

I was trying to compile this example program using GCC (tested versions 4.5.1, 4.6.3, 4.8.4):

#include <iostream>
#include <iomanip>
#include <ctime>
#include <chrono>

using std::chrono::system_clock;

int main()
{
    system_clock::time_point now = system_clock::now();
    std::time_t now_c = system_clock::to_time_t(
                            now - std::chrono::hours(24));
    std::cout << "One day ago, the time was "
              << std::put_time(std::localtime(&now_c), "%F %T") << '\n';
}

But it tells me:

prog.cpp: In function 'int main()':
prog.cpp:14:18: error: 'put_time' is not a member of 'std'

I thought, probably it's not implemented yet. So I tried to check the implementation status for this function. I only found this page:

but there I could not find any note on put_time or chrono or alike. Can anyone point me to a resource that provides information on the implementation status for this library?

moooeeeep
  • 31,622
  • 22
  • 98
  • 187

2 Answers2

82

See TODO extended iomanip manipulators std::get_time and std::put_time for gcc 4.8.0.

See also Cross Platform way to get the time of day? claiming that is not implemented in 4.7.0.


UPDATE: As the gcc developer Jonathan Wakely confirmed below: The std::get_time and std::put_time manipulators are still missing in gcc 4.9.


UPDATE: Jonathan Wakely closed this ticket on 22 Dec, 2014:

Fixed for GCC 5

Thanks simonwo for letting me know about it.

Community
  • 1
  • 1
Ali
  • 56,466
  • 29
  • 168
  • 265
  • 2
    GCC 4.9 has been released - it seems it's neither in there, isn't it? – ollo Apr 23 '14 at 13:22
  • 6
    @ollo As [Jonathan has confirmed](http://stackoverflow.com/questions/14136833/stdput-time-implementation-status-in-gcc/14137287?noredirect=1#comment35569824_14142342), gcc 4.9 still lacks these functionalities. :( Yeah, that is sad. – Ali Apr 23 '14 at 14:38
  • @ollo Still, it is sad, I would use those manipulators too. :( – Ali Apr 23 '14 at 14:43
  • 1
    According to the ticket, this is implemented in GCC 5. – simonwo Mar 05 '15 at 21:07
20

You might have noticed the link you gave doesn't list any parts of the library! But below the table it says:

The status of the library implementation can be tracked in this table

That table notes that std::get_time and std::put_time manipulators are not implemented yet.

Edit: put_time is now on the GCC development trunk.

Jonathan Wakely
  • 166,810
  • 27
  • 341
  • 521