Re: lug-bg: SQUID access.log
- Subject: Re: lug-bg: SQUID access.log
- From: mr700@email.domain.hidden (Doncho Gunchev)
- Date: Wed, 9 Jul 2003 12:01:59 +0200
On Wed 09 Jul 2003 09:07, Jordan Merachev wrote:
<em class="quotelev1">> Zdarveite,
<em class="quotelev1">>
<em class="quotelev1">> Edin elementaren vapros. Kak se razbira chasa i datata na zapisite v
<em class="quotelev1">> access.log na SQUID.
<em class="quotelev1">>
<em class="quotelev1">> Jordan
primer:
---
1057740970.436 235 xxx.xxx.xxx.xxx TCP_REFRESH_HIT/200 385 GET
http://www.globul.bg/p/pool_top_right.gif - FIRST_UP_PARENT/xxx.xxx.xxx.xxx
image/gif
---
1057740970 e unixtime na zaqwkata... ako polzwame perl....
--- cut ---
#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw(strftime);
use Time::Local;
my $input = shift || scalar time(); #die('Give unix time as first parameter');
my $time_str = strftime("%Y-%m-%d %H:%M:%S %Z\t(%z)", localtime($input));
unless (strftime("%Y-%m-%d %H:%M:%S", localtime($input)) =~
m/^(\d{4})\-?(\d{2})\-?(\d{2})\ ?(\d{2}):?(\d{2}):?(\d{2})/) {
die('Invalid time');
}
my $time = timelocal($6, $5, $4, $3, $2 - 1, $1);
print("Input : $input\n");
print("Unix Time : $time\n");
print("Human Time: $time_str\n\n");
--- cut ---
Input : 1057740970
Unix Time : 1057740970
Human Time: 2003-07-09 11:56:10 EEST (+0300)
sledwahtite 3 tzifri mislq sa milisekundi no... ako sa ti wajni wij docs :)
obratnoto preobrazuwane ako za nqkogo e interes primerno stawa taka:
--- cut ---
... syshtite use ...
my $input = shift || die('Required time as first parameter (YYYY[-]MM[-]DD[
]HH[:]MM[:]SS)');
unless ($input =~ m/^(\d{4})\-?(\d{2})\-?(\d{2})\ ?(\d{2}):?(\d{2}):?(\d{2})/)
{
die('Invalid time: "' . $input . '"');
}
my $time = timelocal($6, $5, $4, $3, $2 - 1, $1 - 1900);
my $time_str = strftime("%Y-%m-%d %H:%M:%S %Z\t(%z)", localtime($time));
print("Input : $input\n");
print("Unix Time : $time\n");
print("Human Time: $time_str\n\n");
--- cut ---
hope this helps...
--
Regards,
Doncho
============================================================================
A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers).
http://www.linux-bulgaria.org - Hosted by Internet Group Ltd. - Stara Zagora
To unsubscribe: http://www.linux-bulgaria.org/public/mail_list.html
============================================================================
|