You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by "Christopher H. Laco" <cl...@chrislaco.com> on 2005/09/01 17:13:08 UTC

What format is $dirent->time() ?

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

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

Posted by "Christopher H. Laco" <cl...@chrislaco.com>.
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