[Xastir-dev] Timestamp in TNC log

Henk de Groot henk.de.groot at hetnet.nl
Tue Sep 7 16:44:29 EDT 2004


Hello Curt,

At 17:07 6-9-2004 -0700, Curt Mills wrote:
>I'm still getting timestamps that look like this:
>
>     # Mon Sep  6 17:04:46 PDT 2004

I guess the timestamps I had before the 4th of April were generated on a 
Linux system, I copied my home directory to Cygwin and continued from there.

I did a small test with the next code:

----------------------------------------------------------------------
#include <time.h>
#include <stdlib.h>

void get_timestamp(char *);
time_t sec_now(void);

int main(int argc, char *argv[])
{
     char timestring[100+1];

     get_timestamp(timestring);
     printf("%s\n", timestring);

     return 0;
}

time_t sec_now(void) {
     time_t timenw;
     time_t ret;

     ret = time(&timenw);
     return(ret);
}

void get_timestamp(char *timestring) {
     struct tm *time_now;
     time_t secs_now;

     secs_now=sec_now();
     time_now = localtime(&secs_now);
     (void)strftime(timestring,100,"%a %b %e %T %Z %Y",time_now);
}
----------------------------------------------------------------------

"sec_now" and "get_timestamp" are directy from XAstir's util.c, when I run 
it I get:

----------------------------------------------------------------------
Henk at Targa ~
$ cc c.c -o c

Henk at Targa ~
$ ./c
Tue Sep  7      2004

----------------------------------------------------------------------

As you see, strftime on Cygwin does not understand all the variables. 
According to the manual it indeed does not understand %T.

A safe replacement for %T is %H:%M:%S. I think even the oldest 
implementations support that. The output on Cygwin becomes in that case:

Tue Sep  7 22:31:57     2004

No timezone name tough, TZ is normally not set in Cygwin. When I specify 
TZ=MET-1DST then strftime thinks the timezone name is DST...

The behavior of strftime is exactly the same as the 'date' command.

Kind regards,

Henk.






More information about the Xastir-dev mailing list