[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: API call to retrieve server timestamp / timestamps as offsets?

From: Nik Clayton <nik_at_ngo.org.uk>
Date: 2006-11-01 18:13:58 CET

John Peacock wrote:
> Nik Clayton wrote:
>> my $current_time = time(); # Seconds since epoch, in UTC
>
> This is your problem. If I'm correct in thinking you are using HTTP as a
> transport, parse the server generated Date header and use that as your
> current_time (parsed to seconds since epoch).

I'm using SVN::Client, so I can use any of the Subversion RA mechanisms.

>> I know, and agree, that this is a configuration problem on the client.
>> I'm suggesting that client applications could work around this problem
>> with a little help from Subversion. Perhaps with an API call, something
>> like:
>>
>> my $current_time = SVN::Client::get_time_on_server();
>
> Yes, but that time is wrong one second later... ;-)

That's fine. You request the current time *after* you've requested some
data that includes timestamps, not before.

   [...]

   my $ctx = SVN::Client->new();
   my $dirents = $ctx->ls($some_uri, $some_rev, 0);
   my $current_time = $ctx->get_time_on_server();

   foreach my $name (keys %$dirents) {
       printf("%s is %d seconds old\n",
         int($current_time - $dirents->{$name}->time()));
   }

   [...]

N

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Nov 1 18:14:31 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.