borland time_t conversion

T

Tomas Deman

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
 
R

Richard Bos

Tomas Deman said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top