Re: ctime double double check
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Thu, 08 Mar 2007 16:36:51 -0800
Flash Gordon <spam@xxxxxxxxxxxxxxxxxx> writes:
aisling.cronin@xxxxxxxxx wrote, On 08/03/07 15:37:
<snip>
Thank you all for pointing out all my coding errors, I have fixed it
up, hopefully this is correct
#include <time.h>
#include <stdio.h>
int main (void)
{
time_t Timestamp;
char *CTime;
Timestamp= 1144412677847 ;
CTime=ctime(&Timestamp);
printf ("The Time is %s ", CTime);
}
I am not sure of what to cast the timestamp as I get ..
test.c:8: warning: integer constant is too large for "long" type
Then perhaps the compiler knows it does not fit it to a long and it
thought you should know? It might fit in to an unsigned long.
1144412677847 is between 2**40 and 2**41. If it doesn't fit into a
long, it's not likely to fit into an unsigned long.
To the OP: where did you get the number 1144412677847, and what makes
you think it's a valid time_t value?
As others have pointed out, the standard imposes very few requirements
on how time_t is represented. (In my opinion, it's under-specified.)
There happens to be a very common system-specific representation,
where a time_t is an integer type (usually signed, usually 32 bits,
sometimes 64 bits) representing the number of seconds since 1970-01-01
00:00:00 GMT. Assuming that particular representation, the value
1144412677847 represents a time in late December of the year 38,234.
(It may or may not be coincidental that if you divide it by 1000, it
represents a time about 13 months ago.)
Any program that works with specific numeric time_t values is
non-portable, perhaps needlessly so. If you really need to work with
the specific representation I described above, you should ask in a
system-specific newsgroup, perhaps comp.unix.programmer.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- Follow-Ups:
- Re: ctime double double check
- From: aisling . cronin
- Re: ctime double double check
- References:
- ctime double double check
- From: aisling . cronin
- Re: ctime double double check
- From: Eric Sosman
- Re: ctime double double check
- From: aisling . cronin
- Re: ctime double double check
- From: Flash Gordon
- ctime double double check
- Prev by Date: Re: array
- Next by Date: Re: array
- Previous by thread: Re: ctime double double check
- Next by thread: Re: ctime double double check
- Index(es):
Relevant Pages
|
|