#include <stdio.h>
#include "parsedate.h"

#define MAX_BUF 65536

main() {
  char buf[MAX_BUF];
  char dbuf[DATE_STRING_LENGTH+1];
  char *p, *last_p;
  char *secPtr, usecPtr;
  long sec, usec;
  int len;
  int count = 0;

  while( (len = read(0, buf, MAX_BUF)) ) {
    buf[len] = '\0';
    for ( last_p = buf; p = strchr( last_p, '\n' ); last_p = p+1 ) {
      secPtr = strstr(last_p, "NL.SEC=");
      if ( secPtr == NULL )
	continue;
      sscanf( secPtr + 7, "%ld", &sec );
      if ( NULL == (p = strstr(last_p, "NL.USEC=")) )
	continue;
      sscanf( p + 8, "%ld", &usec );
      if ( 0 == Nlv_pdConvertDate( sec, usec, dbuf ) )
	printf("%s\n",dbuf);
      else
	fprintf(stderr,"error\n");
    }
  }

  fprint(stderr,"Done\n");
  exit(0);
}
