[SGVLUG] timediff - my 1st ever C program that I have GPLd

Matthew Campbell dvdmatt at gmail.com
Wed Jan 5 08:34:30 PST 2011


I wrote this several years ago.  It is not a trivial problem due to
all the various date formats in common use.

For example, what date is this?:  04-05-11

Matt

Hint:  Think European

On Wed, Jan 5, 2011 at 1:51 AM, Claude Felizardo <cafelizardo at gmail.com> wrote:
> Cool.
> Actually I could use a program to calculate the diff given time stamps
> from say syslog or what ever.  It would be nice if it could various
> formats with optional date and/or time components and calculate the
> difference and printing the diff in either seconds or hh:mm:ss, etc.
> For example, I might want want to be able to cut and paste the time
> stamps to find the interval between two or more events in
> /var/log/messages
>
> timediff Jan  5 01:45:01 01:47:35
>
> Note how I have left off the date component of the 2nd datetime.
> It would return the difference in both mm:ss and well as total seconds.
>
> Bonus if it could handle more than two datetime on the command line or
> possibly read from stdin calculating the diff between each entry until
> end of file.
>
> claude
>
>
>
> On Tue, Jan 4, 2011 at 9:38 PM, juanslayton @dslextreme.com
> <juanslayton at dslextreme.com> wrote:
>> You put it up on Savannah yet?
>> John
>>
>> On Tue, Jan 4, 2011 at 8:34 PM, Robert Leyva <mrflash818 at geophile.net>
>> wrote:
>>>
>>> A C-language program of something simple, and fun, to calculate the
>>> difference between two dates, for using in a shell script, for example :)
>>>
>>> http://mrflash818.geophile.net/php/clang/index.php
>>>  ...and...
>>> http://mrflash818.livejournal.com/108407.html
>>>
>>> I created it because I wanted to figure out some quick averages for kWh
>>> consumption, but could not find a simple preexisting program that does
>>> differences in time as a command line and stand alone program.
>>>
>>>
>>> --
>>> "Knowledge is Power" -- Francis Bacon
>>>
>>> Robert Leyva
>>> mrflash818 at geophile.net
>>>
>>>
>>
>>
>



-- 
Matthew Campbell | Chief Technical Officer
Imagination Games
3450 Cahuenga Blvd. West #103
Los Angeles, CA  90068
818.314.9897 (M)
matt.campbell at imaginationgames.com
www.imaginationgames.com


More information about the SGVLUG mailing list