I need to load in a string of format 16/11/2012 11:00:00 i.e %d/%m/%Y %H:%M and then repeatedly add 900 seconds to it. The code below is an example, could you help me get it working?
#include "stdafx.h"
#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>
#include <sstream>
#include "boost/date_time/local_time/local_date_time.hpp"
int _tmain(int argc, _TCHAR* argv[])
{
unsigned int seconds=900;
using namespace boost::local_time;
std::stringstream ss;
// Set up the input datetime format.
local_time_input_facet *input_facet = new local_time_input_facet("%d/%m/%Y %H:%M");
ss.imbue(std::locale(ss.getloc(), input_facet));
local_date_time date(not_a_date_time);
ss.str("16/11/2012 11:00:00");
ss >>date;
local_date_time now=date+seconds;
std::cout << now << std::endl;
return 0;
}
Any help would be greatly appreciated, James
I don't have boost in hands right now, please try something like:
date + boost::posix_time::seconds(900)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With