/********************************************************************************************

format_dstlsonic.c


Wed Jun 30 21:49:08 1993  ms U V W C\n"


********************************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

int main( int argc , char **argv )
{
	char	buf[132]	;	/* line buffer			*/
	int	nline		;	/* number of lines processed	*/	
	char	dow[8]		;	/* day of week string		*/
	char	mon[8]		;	/* month string			*/
	char	hms[16]		;	/* hh:mm:ss string		*/
	int	dom		;	/* day of month (1-31)		*/
	int	hh		;	/* hour (00:24)			*/
	int	mm		;	/* minute (00:59)		*/
	int	ss		;	/* second (00:59)		*/
	int	yy		;	/* year (2000,...)		*/
	int	ms		;	/* millisecond (000:999)	*/
	int	U , V , W 	;	/* wind components (cm/s)	*/
	int	S		;	/* speed-of-sound (cm/s)	*/
	struct	tm	tt	;	/* broken down time structure	*/
	time_t	ct		;	/* calander time		*/
	time_t	ct1		;	/* calander time of first line	*/
	double	ctms		;	/* calander time with ms added	*/
				
/* loop until EOF reached
*/

	nline = 0 ;	/* number of lines processed	*/
	
	while( fgets( buf , 131 , stdin ) != NULL )
	{
	
/* extract the date, time, ...
*/
		sscanf( buf , "%s %s %d %s %d %d %d %d %d %d" ,
			dow ,
			mon ,
			&dom ,
			hms  ,
			&yy , &ms ,
			&U , &V , &W , &S ) ;
			
/* extract hh mm ss from the hms string
*/
		hh = 10 * (hms[0] - '0') + (hms[1] - '0') ;
		mm = 10 * (hms[3] - '0') + (hms[4] - '0') ;
		ss = 10 * (hms[6] - '0') + (hms[7] - '0') ;
	
/* convert to broken down time
*/
		tt.tm_mon = 8 ;		/* assume month = Sep	*/
	
		if( strncmp( mon , "Jan" , 3 ) == 0 )	tt.tm_mon = 0  ;
		if( strncmp( mon , "Feb" , 3 ) == 0 )	tt.tm_mon = 1  ;
		if( strncmp( mon , "Mar" , 3 ) == 0 )	tt.tm_mon = 2  ;
		if( strncmp( mon , "Apr" , 3 ) == 0 )	tt.tm_mon = 3  ;
		if( strncmp( mon , "May" , 3 ) == 0 )	tt.tm_mon = 4  ;
		if( strncmp( mon , "Jun" , 3 ) == 0 )	tt.tm_mon = 5  ;
		if( strncmp( mon , "Jul" , 3 ) == 0 )	tt.tm_mon = 6  ;
		if( strncmp( mon , "Aug" , 3 ) == 0 )	tt.tm_mon = 7  ;
		if( strncmp( mon , "Sep" , 3 ) == 0 )	tt.tm_mon = 8  ;
		if( strncmp( mon , "Oct" , 3 ) == 0 )	tt.tm_mon = 9  ;
		if( strncmp( mon , "Nov" , 3 ) == 0 )	tt.tm_mon = 10 ;
		if( strncmp( mon , "Dec" , 3 ) == 0 )	tt.tm_mon = 11 ;

		tt.tm_year	= yy - 1900 ;
		tt.tm_mday	= dom	;
		tt.tm_hour	= hh	;
		tt.tm_min	= mm	;
		tt.tm_sec	= ss	;

/* convert tt to calander time
*/
		ct   = mktime( &tt ) ;
		ctms = ((double) ct) + .001 * ms ;

/* save the calander time of the first line
*/
		if( nline == 0 ) ct1 = ct ;
	
/* output the line
*/
		printf( "%.3f %d %d %d %d\n" , (ctms - ct1) , U , V , W , 2*S ) ;
	
/* process the next line
*/
		++nline ;
	}
	
/* exit
*/
	return( 1 ) ;
}
 