*BSD News Article 86637


Return to BSD News archive

Newsgroups: comp.unix.programmer,comp.unix.bsd.freebsd.misc
From: Alexander Indenbaum <baum@actcom.co.il>
Subject: Re: Calculate time from ascii-time
In-Reply-To: <5atj3s$cs7@news.euro.net>
X-Nntp-Posting-Host: actcom.co.il
Content-Type: TEXT/PLAIN; charset=US-ASCII
Message-ID: <Pine.SUN.3.93-heb-2.07.970110192015.25879A-100000@actcom.co.il>
To: sake@euro.net
Sender: news@actcom.co.il (News)
Organization: ACTCOM - Internet Services in Israel
References: <5atj3s$cs7@news.euro.net>
Mime-Version: 1.0
Date: Fri, 10 Jan 1997 17:22:48 GMT
Lines: 43
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.wildstar.net!newsfeed.direct.ca!nntp.portal.ca!news.bc.net!arclight.uoregon.edu!enews.sgi.com!news.sgi.com!swrinde!cssun.mathcs.emory.edu!andromeda.vec.net!news.new-york.net!actcom!actcom.co.il!baum
Xref: euryale.cc.adfa.oz.au comp.unix.programmer:48594 comp.unix.bsd.freebsd.misc:33929

On 7 Jan 1997, Sake Blok wrote:

> Hi,
> 
> For processing some log-files I would like to calculate the amount of
> seconds since Epoch in a script. The entries in the log-file are of the
> following form:   Tue Jan  7 14:07:51 MET 1997
> 
> The script itself will be in Perl, so if it can be done (easily) from 
> withing Perl, that's great, if not an external program in C will do too.
> 
> I think I can use mktime(3) for the purpose but I would think somebody would
> already have done so and it feels stupid to invent the wheel all over
> again :-)

There are too perl functions:
localtime ( built in ) - which converts time fro, Epoch to local time.
There is also back convertation:
timelocal ( it is library function ) which converts local time to time
since Epoch

> 
> So if anybody has some sourcecode already for calculating seconds-since-epoch
> from an ascii-time-string, I would apreciate it.
> 
> Thanks,
> 
> 
> Sake
> --
>    +------------------- There is a purpose to time: --------------------+
>    | Sake Blok                                       EuroNet Internet |
>    | e-mail: sake@euro.net                          Herengracht 208-214 |
>    | http://www.euronet.nl/~sake                     1016 BS  Amsterdam |
>    | telephone: +31 (0)20 625 6161                    The Netherlands |
>    +---------- It prevents everything from happening at once.-----------+
> 
> 

  Alexander Indenbaum
  baum@actcom.co.il