| Sebastian Luque 2005-11-07, 9:55 pm |
| "William James" <w_a_x_man@yahoo.com> wrote:
[...]
> /^Stage [0-9]/ {
> oldstage = stage
> oldincrement = increment
> oldstart = start
> stage = $2 + 0
> increment = substr($0,index($0,"*")+1) + 0
> start = get_start_time( $0 )
> # If there was a previous stage, and it wasn't
> # a stage 2, we need to generate its lines now.
> if ( oldstage && oldstage != 2 )
> { for (t=oldstart; t<start; t += oldincrement)
> print format_time(t) ",,,,"
> }
> next
> }
> 2 == stage {
> print format_time( start) "," $0
> start += increment
> }
> # Input: 26/04/05 start 08:30:00
> # Output: 2005 04 26 08 30 30
> function fix_date_string( s, a )
> { split( s, a, /[ :\/]/ )
> return sprintf( "%s %s %s %s %s %s",
> 2000+a[3], a[2], a[1], a[5], a[6], a[7] )
> }
> function get_start_time( s )
> {
> match( s, /Date / )
> return mktime( fix_date_string( substr(s, RSTART+RLENGTH) ))
> }
> function format_time( timestamp )
> { return strftime( "%d/%m/%Y, %H:%M:%S", timestamp )
> }
That works great and very instructive! Thank you.
--
Sebastian P. Luque
|