Email List: Xaustin-review-lX
[All Lists]

Bug in TC2-d2 strptime()

To: yyyyyyyyyyyyyyy@xxxxxxxxxxxxx
Subject: Bug in TC2-d2 strptime()
From: yyyyyyyyy@xxxxxxx
Date: Thu, 24 Jul 2003 10:06:47 +0100 (BST)
        Bug report from : Michael Kerrisk , self

(Note that the reply-to line automatically redirects 
to yyyyyyyyyyyyyy@xxxxxxxxxxxxx for further discussion on bug reports)

@ page 1 line 44720 section strptime() comment {example for strptime()}

Problem:

This is an EXAMPLE for the strptime() man page.  Line number 
references are to TC1.  I thought the additional use of mktime()
worthwhile since I myself recently was educated that in this scenario 
we must set tm_isdst if we then go on to call mktime().


Action:

Change

"None"

to the following:

The following example demonstrates the use strptime() 
to convert a string into broken-down time.  The broken-down
time is then converted into seconds since the Epoch using
mktime().

struct tm tm;
time_t t;

if (strptime("6 Dec 2001 12:33:45", "%d %b %Y %H:%M:%S", &tm) == NULL)
    /* Handle error */;

printf("year: %d; month: %d; day: %d;\n",
        tm.tm_year, tm.tm_mon, tm.tm_mday);
printf("hour: %d; minute: %d; second: %d\n",
        tm.tm_hour, tm.tm_min, tm.tm_sec);
printf("week day: %d; year day: %d\n", tm.tm_wday, tm.tm_yday);

tm.tm_isdst = -1;           /* Not set by strptime(); tells mktime()
                               to determine if daylight saving time
                               is in effect */
t = mktime(&tm);
if (t == -1)
    /* Handle error */;
printf("seconds since the Epoch: %ld\n", (long) t);

<Prev in Thread] Current Thread [Next in Thread>
  • Bug in TC2-d2 strptime(), mtk-lists <=