|
Boost : |
Subject: Re: [boost] Cross-platform date/time problems
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2009-11-02 14:37:31
Zachary Turner wrote:
> On Mon, Nov 2, 2009 at 12:38 PM, Andrey Semashev
> <andrey.semashev_at_[hidden]>wrote:
>
>> Zachary Turner wrote:
>>
>> Anyway, I don't think that bringing Windows-specific code to other
>>>> platforms is a good idea. If you want cross-platform code, use
>>>> cross-platform types, such as time_t, ptime or local_time.
>>>>
>>>>
>>>> That's just it, I'm trying to use ptime.
>> Then why not simply send ptime over the network?
>
>
> Using what method? by sending the result of ptime::ticks()? If so, how do
> I reconstruct a ptime from the result of this?
IIRC, currently you have to separately serialize date and time. The date
is simply a number of days since the base date. The time has ticks() and
ticks_per_second() or something like that. So there is no problem to
reconstruct the correct ptime on another machine, even with different
time resolution capability.
> Also, the server that this
> information is being sent to is written in Java, and it needs to be able to
> understand whatever is sent across (i.e. extract day/month/year/etc
> information)
I don't see a problem with it. Anyway, I'm more inclined to improve
ptime portability instead of porting FILETIME.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk