22 Jul
2004
22 Jul
'04
2:45 p.m.
Has anybody ever implimented a to_time_t function/method for the ptime class to create a time_t from a ptime. I tried doing it similar to the way from_time_t does it but I'm not getting the right answer. It's nice that you can convert from a time_t for use with legacy code but sometimes you need to go back the other way. Herer is my to_time_t function that does not appear to be working inline std::time_t to_time_t(ptime t) { if( t == neg_infin ) return 0; else if( t == pos_infin ) return LONG_MAX; ptime start(gregorian::date(1970,1,1),time_duration(0,0,0)); return (t-start).total_seconds(); } Thanks,