1

So I am recently trying to convert some time strings to ptime/local_date_time so I can convert them from whatever zone to utc. The format in question is "%a, %d %b %Y %H:%M:%S %q"

I am using the following to convert:

boost::local_time::local_time_input_facet* timeFacet = new boost::local_time::local_time_input_facet("%a, %d %b %Y %H:%M:%S %q");
std::stringstream ss;
ss.str(timeStr);
ss.imbue(std::locale(ss.getloc(), timeFacet));

boost::local_time::local_date_time localDateTime(boost::date_time::not_a_date_time);
ss >> localDateTime;

However, this ignorres the timezone, the localDatetime will just state its already in the UTC timezone, when for example I am passing: Wed, 13 Apr 2022 17:50:32 -0500

This is not quit right, I did try %ZP but it does not work for time offset, how can I get around this to be able to get the time zone set in the local_date_time?

Thanks

peti446
  • 330
  • 1
  • 4
  • 12
  • Do you have a documentation link for %q? I don't think I've seen it before – sehe Apr 14 '22 at 13:27
  • 1
    After some tinkering, the only thing I was able to make work was this oldie: https://stackoverflow.com/a/44091087/85371 so e.g. https://wandbox.org/permlink/t9JQ9O49l9gfhxiO Note that it doesn't _retain_ the timezone, but perhaps you only want the UTC converted value anyways? – sehe Apr 14 '22 at 14:40

0 Answers0