1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <boost/date_time.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <iostream>
#include <sstream>
#include <memory>
std::string get_curr_date() {
auto date = boost::date_time::second_clock<boost::posix_time::ptime>::universal_time();
//boost::posix_time::time_facet* facet = new boost::posix_time::time_facet("%a, %d %b %Y %H:%M:%S GMT");
std::unique_ptr<boost::posix_time::time_facet> facet(new boost::posix_time::time_facet("%a, %d %b %Y %H:%M:%S GMT"));
std::ostringstream os;
os.imbue(std::locale(os.getloc(), facet.get()));
os << date;
return os.str();
}
int main() {
std::cout << get_curr_date() << std::endl;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
g++ -std=c++11 -O2 -Wall -pedantic -pthread main.cpp && ./a.out
+ g++ -std=c++11 -O2 -Wall -pedantic -pthread main.cpp
+ ./a.out
/tmp/1374462499-618203525/cmd.sh: line 8: 23780 Segmentation fault      (core dumped) ./a.out