469,358 Members | 1,659 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,358 developers. It's quick & easy.

borland time_t conversion

Hi all,

I have a problem converting a borland cpp (v4.52) time_t value to a visual
basic date.
What does borland exactly store? I heard this should be #seconds since
1/1/1970 0:00 in EST time. How can borland do this in dos without having set
the TZ environment variable?
I'd like to know what borland stores...

Thanks in advance,
Tomas Deman
Nov 14 '05 #1
1 2901
"Tomas Deman" <to********@PLEASEDONTSPAMhotmail.com> wrote:
I have a problem converting a borland cpp (v4.52) time_t value to a visual
basic date.
What does borland exactly store?
Who knows? Ask Borland. This is not a C matter. All the C Standard says
is that time_t is an arithmetic type used for storing calendar time; it
doesn't say anything about _how_ it does this. A long double storing a
Julian Date is legal.

FWIW, since different systems and indeed different compilers for the
same system implement time_t differently, you should never store a
time_t in a file for other programs to use. Store a well-defined date
format instead; for example, the ISO yyyymmddhhmmss format. mktime() and
strftime() are ideal for this.
I heard this should be #seconds since
1/1/1970 0:00 in EST time. How can borland do this in dos without having set
the TZ environment variable?


It can't, so it is unlikely that that is what it stores. Seconds since
0/0/1980[1] 00:00 in whatever timezone is local to the computer clock is
more likely. Now work out how many bytes it uses, what endianness it
has, and how many spacing bits there are, and you're partly on the way
to figuring out the format.
As I said: asking the C program (or, for that matter, the VB program,
the Pascal program, or whatever program wants to communicate with
someone else) to store a decent format in the first place is probably
less hassle.

Richard

[1] No kidding: set an MS-DOS file date to all-bits-zero and do a DIR.
Nov 14 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by HMS Surprise | last post: by
22 posts views Thread by smartwolf agassi via DotNetMonster.com | last post: by
3 posts views Thread by thelaery | last post: by
7 posts views Thread by Angus Comber | last post: by
2 posts views Thread by MrBlueSky | last post: by
3 posts views Thread by pbrama | last post: by
45 posts views Thread by loudking | last post: by
3 posts views Thread by Jonathan | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.