date_time O/S conversion routine limitation

View: New views
2 Messages — Rating Filter:   Alert me  

date_time O/S conversion routine limitation

by Zachary Turner-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello list,

Apologies for the cross-post, this originally went to the boost-users list a day or so ago 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());
    }
    else
    {
        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::uint64_t?

Zach
_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Re: date_time O/S conversion routine limitation

by Zachary Turner-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Nov 1, 2009 at 12:12 AM, Zachary Turner <divisortheory@...> wrote:
Hello list,

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

Agh, my hand-eye coordination is failing me tonight.  This was supposed to go to boost dev list.   Third time's a charm I suppose :(

Zach

_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users