On Fri, 2005-01-07 at 21:05 -0700, Jeff Garland wrote:
On Fri, 07 Jan 2005 22:44:13 -0500, Stephen torri wrote
I need an example of taking a time duration in seconds and converting it to a date using Boost::Date_Time. For example,
805168227 seconds (time from December 31st, 1969, at 4:00 P.M.)
= approx. 25 years, 194 days, 1 hr, 50 minutes, 27 seconds
= File created on 1994 June 15 5:50:27
(Conversion did not account for leap years).
I'm not quite sure what you are asking. You have seconds since a known epoch and you want to create a date from that? It would be something like:
ptime epoch(date(1969, Dec, 31), hours(16)); //4 pm on dec 31 1969 seconds s(...); //whatever //what?
Or is seconds since creation that you have and what to backtrack to the date?
I apologize for the confusion. I have two fact: time of creation and the epoch. The time of creation is given as the number of seconds that have elapsed since the epoch. The value I read from a file header is in seconds. So I want to do: Epoch + seconds = date & time. Something like: ptime epoch(date(1969,Dec,31), hours(16)); seconds s_time (805168227); ptime creation_date = epoch + s_time; std::cout << "File created: " << creation_date.toString(); Stephen