Boost logo

Boost :

Subject: [boost] Cross-platform date/time problems
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-11-01 01:15:15

Hello list,

Apologies for the cross-posting, this originally went to the boost-users
list but it got no responses, and then I also realized it was actually more
appropriate here.

Suppose I have a cross-platform agent that communicates with a server.
Agent from platform X sends a message to the server which contains a
date/time. Server sends a message to another agent running platform Y with
the same date/time. In practice X/Y are always either windows/linux or
linux/windows. The server always tells the agent which platform's native
format the time is represented in, so there should be no problem. Ideally
I'd like to write the following code:

    ptime time;
    if (msg.is_from_windows())
        time = from_ftime<ptime>(msg.time());
        time = from_time_t(msg.time());

But this doesn't work because from_ftime<> is not defined on linux. If
from_ftime<> is already templated on the FILETIME type, is there any reason
it needs to be #ifdef'd out on non-windows platforms? I mean, a FILETIME
is really just a uint64, can't the templated function also just operate on a


Boost list run by bdawes at, gregod at, cpdaniel at, john at