Created
September 19, 2013 23:38
-
-
Save redotics/6631387 to your computer and use it in GitHub Desktop.
Manipulate Boost posix time output # g++ boostposixtime.cpp -o boostposixtime; ./boostposixtime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// to have the cout ("equivalent" to printf) | |
#include <iostream> | |
// to have string stream | |
#include <sstream> | |
#include <boost/date_time/posix_time/posix_time.hpp> | |
#include <boost/date_time/posix_time/posix_time_io.hpp> | |
using namespace boost::posix_time; | |
using namespace std; | |
int main(int argc, char **argv) { | |
//time_facet *facet = new time_facet("%d-%b-%Y %H:%M:%S"); | |
time_facet *facet1 = new time_facet("%a, %d %b %Y %H:%M:%S %Z"); | |
time_facet *facet2 = new time_facet("%a, %d %b %Y %H:%M:%S GMT"); | |
stringstream MyStr; | |
cout.imbue(locale(cout.getloc(), facet1)); | |
MyStr.imbue(locale(cout.getloc(), facet2)); | |
cout << second_clock::local_time() << endl; | |
cout << microsec_clock::universal_time() << endl; | |
MyStr << microsec_clock::universal_time() ; | |
cout << "--- Display My own string: " << MyStr.str() << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment