[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Date processing
From: |
Marcus G. Daniels |
Subject: |
Re: Date processing |
Date: |
15 Nov 1999 23:06:27 -0800 |
User-agent: |
Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4 |
>>>>> "B" == Benedikt Stefansson <address@hidden> writes:
B> For example I can't for the life of me understand why this
B> program crashes with a seg fault:
There are three problems with this test program:
1) The reason it crashes is because you are passing pointers
to strptime that don't point to anything.
2) time_t is relative to 1970, so 1900 won't work.
3) difftime is first_argument - second_argument
Here's the updated test program:
#include <time.h>
#include <stdio.h>
int
main (int argc, const char **argv)
{
struct tm tm1;
struct tm tm2;
double diff;
strptime ("1/1/1980", "%m/%d/%Y", &tm1);
strptime ("11/15/1999", "%m/%d/%Y", &tm2);
diff = difftime (mktime (&tm2), mktime (&tm1));
printf ("Difference is %f\n", diff);
return 0;
}
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.