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

Re: What format is $dirent->time() ?

From: Christopher H. Laco <claco_at_chrislaco.com>
Date: 2005-09-01 22:15:00 CEST

Christopher H. Laco wrote:
> Using the SVN::Client to browse a repository, I use SVN::Client->ls to
> fetch all items in a certain level.
>
> For each item I can get the last mod time:
>
>> =item $dirent-E<gt>time()
>>
>> Time of created_rev (mod-time).
>
>
> This yields me roughly:
>
>> 1125338412570734
>
>
> The first half of that looks like seconds-since-epoch time:
>
>> 1125594190
>
>
> So what's tha rest of that data?
>
> -=Chris

I figured this out. It's not terribly intuitive from the perldoc pod.
I'm sure it's buried in the c stuff, but that does your average perl
programmer much good.

$dirent->time appears to return epoch+miliseconds:

        my $time = $dirent->time; # 1125338412570734
        my ($epoch, $mili) = (substr($time, 0, 10), substr($time, 10));

        localtime($epoch) / gmtime($epoch) return the expected results.

        my $totalmili = ($epoch*1000)+$mili;

What started this all was sending the easiest thing to javascript for
local display of the revision dates:

        <javascript type="text/javascript">
                # we passed in $epoch*1000+$mili
                my RevDate = Date(1125597206000);
                alert(RevDate.toLocaleString());
        </javascript>

It all works correctly, so I can only assume that the above is really
what ->time() returns.

-=Chris

Received on Thu Sep 1 22:19:11 2005

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

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