qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Conway <acon...@redhat.com>
Subject Re: Constructing abstime from uint64_t
Date Wed, 07 Apr 2010 13:22:24 GMT
On 04/06/2010 10:29 PM, Andrew Stitcher wrote:
> On Tue, 2010-04-06 at 15:33 -0400, Alan Conway wrote:
>> I need to (de)serialize AbsTime timestamps. I can convert an AbsTime to a
>> uint64_t with uint64_t(Duration(abstime)) but I don't see how to convert back to
>> an AbsTime. I can just add a constructor but wanted to check with you if I'm
>> missing the intent.
> The problem here is that fundamentally the class is designed not to show
> it's epoch value. The fact you can wheedle it out by going via a
> Duration is not intentional!
> [BTW Duration&  AbsTime encapsulate an int64_t so using uint64_t is
> incorrect. Both are allowed to be negative - Duration -ve indicates
> before the time you asked about, AbsTime -ve indicates before the Epoch]
> The external representation can't simply be the nanosec count in AbsTime
> as different platforms have different Epochs. This is certainly true
> between Windows and Unix.
> I guess there needs to be an explicit way to convert a specific
> date/time to an AbsTime so that you can use the existing differencing
> operations as you can get a Duration out of the difference between the
> AbsTime you're serialising and some fixed Epoch AbsTime. And equally you
> can construct an AbsTime out of an Epoch AbsTime and a Duration.
> Actually I suppose you could just declare a new static AbsTime as the
> Epoch and make sure it represents the same time across all platforms.
> Then use it for serialisation. That would avoid needing to do the
> general Date->AbsTime thing.
> This has rambled a bit, get back to me if it's not clear, I could add an
> Epoch AbsTime for you if it's not clear how to do it fairly easily.

Here's a patch to add an EPOCH constant to Time.h, Steve can you check that I've 
got the windows part right?

View raw message