Board index » cppbuilder » Time zone returned empty from the function 'strftime' in BCC32 command-line compiler

Time zone returned empty from the function 'strftime' in BCC32 command-line compiler


2005-04-06 11:09:28 PM
cppbuilder40
Hello,
I have a small question, that I am sure most of you are familiar with.
( I am not a programmer, so I don't know where too look up).
I have The Borland Cpp compiler Ver. 5.5 command-line tools installed.
I created this program (modified from the example in the documentation):
"
/* strftime example */
#include <stdio.h>
#include <time.h>
int main(void)
{
struct tm *time_now;
time_t secs_now;
char str[80];
tzset();
time(&secs_now);
time_now = localtime(&secs_now);
strftime(str, 80, "%X (%Z)", time_now);
printf("%s\n",str);
return 0;
}
"
After compiling it with this command:
"
bcc32 EchoTime.cpp
"
and running the EXE:
"
EchoTime.exe
"
I get:
"
18:05:18 ()
"
Notice that the time zone is missing. the hour is correct.
Please someone tell me what is the problem ?
I think that some settings in the compiler are missing, but I really
don't know.
ThanQ,
Jonathan Orlev
 
 

Re:Time zone returned empty from the function 'strftime' in BCC32 command-line compiler

"Jonathan Orlev" < XXXX@XXXXX.COM >wrote:
Quote
strftime(str, 80, "%X (%Z)", time_now);
printf("%s\n",str);
I get:
"
18:05:18 ()
"

Notice that the time zone is missing. the hour is correct.

Please someone tell me what is the problem ?
C:\>test
17:35:49 ()
C:\>set TZ=GST-1GDT
C:\>test
17:36:23 (GDT)
C:\>
You machine (just like mine) doesn't have the TZ environment variable
set.
Alan Bellingham
--
ACCU Conference 2005 - 20-23 April, Randolph Hotel, Oxford, UK
 

Re:Time zone returned empty from the function 'strftime' in BCC32 command-line compiler

Hello Alan,
ThanQ for the answer.
I should have mentioned it, but I am not sure this is the problem:
In Vim, the time zone seems to be recognized, even though the TZ
environment variable is not defined.
In other words: There should be a way to retrieve the TZ without using
the TZ variable.
I don't know how, but I have a filling it have something to do with the
compiler.
Maybe there is a DLL other Windows file that the compiler can use to get
it ?
Also, I asked someone to compile the program using Visual C++, and it
works just fine.
I can't say for sure (at this point) that he does not have this value
set, but it is not likely.
Regards,
Jonathan Orlev
"Alan Bellingham" < XXXX@XXXXX.COM >wrote in message
Quote
"Jonathan Orlev" < XXXX@XXXXX.COM >wrote:

>strftime(str, 80, "%X (%Z)", time_now);
>printf("%s\n",str);

>I get:
>"
>18:05:18 ()
>"
>
>Notice that the time zone is missing. the hour is correct.
>
>Please someone tell me what is the problem ?

C:\>test
17:35:49 ()

C:\>set TZ=GST-1GDT

C:\>test
17:36:23 (GDT)

C:\>

You machine (just like mine) doesn't have the TZ environment variable
set.

Alan Bellingham
--
ACCU Conference 2005 - 20-23 April, Randolph Hotel, Oxford, UK
 

{smallsort}

Re:Time zone returned empty from the function 'strftime' in BCC32 command-line compiler

Jonathan Orlev wrote:
Quote
tzset();
The help example for tzset (in BCB5.HLP) shows setting the environment
variable:
time_t td;
putenv("TZ=PST8PDT");
tzset();
time(&td);
You might also look into using the Win32 API (in Win32.hlp)
GetLocalTime()
GetTimeZoneInformation()
 

Re:Time zone returned empty from the function 'strftime' in BCC32 command-line compiler

"Jonathan Orlev" < XXXX@XXXXX.COM >wrote:
Quote
I should have mentioned it, but I am not sure this is the problem:
According to the (Visual C++) documentation, it is.
Quote
In Vim, the time zone seems to be recognized, even though the TZ
environment variable is not defined.
There are other (more reliable) ways to retrieve the time zone. I expect
Vim uses one of those.
Alan Bellingham
--
Me <url:mailto: XXXX@XXXXX.COM ><url:www.doughnut.demon.co.uk/>
ACCU - C, C++ and Java programming <url:accu.org/>
The 2004 Discworld Convention <url:dwcon.org/>
 

Re:Time zone returned empty from the function 'strftime' in BCC32 command-line compiler

Hello Again, Alan,
Quote
According to the (Visual C++) documentation, it is.
Well, I'll check it up.
Quote
There are other (more reliable) ways to retrieve the time zone. I
expect
Vim uses one of those.
Can you give me a clue ?
But this not seems to be the situation here:
I compiled VIM using the BCC compiler, and there the time zone is also
missing.
So I have two binaries of VIM:
1. A pre-compiled version, that I downloaded from the Vim site, with the
time zone works, even though I don't use the TZ variable.
2. My BCC compiled VIM, where the time zone is missing.
So it seems like a problem in the compiler (not a bug, but a missing
setting), or some DLL, or a setting in the operating system that affects
the compiler.
I'll keep checking it up.
ThanQ,
Jonathan Orlev
"Alan Bellingham" < XXXX@XXXXX.COM >wrote in message
Quote
"Jonathan Orlev" < XXXX@XXXXX.COM >wrote:

>I should have mentioned it, but I am not sure this is the problem:

According to the (Visual C++) documentation, it is.

>In Vim, the time zone seems to be recognized, even though the TZ
>environment variable is not defined.

There are other (more reliable) ways to retrieve the time zone. I
expect
Vim uses one of those.

Alan Bellingham
--
Me <url:mailto: XXXX@XXXXX.COM >
<url:www.doughnut.demon.co.uk/>
ACCU - C, C++ and Java programming
<url:accu.org/>
The 2004 Discworld Convention
<url:dwcon.org/>
 

Re:Time zone returned empty from the function 'strftime' in BCC32 command-line compiler

Hello Bob,
Quote
The help example for tzset (in BCB5.HLP) shows setting the environment
variable:

time_t td;
putenv("TZ=PST8PDT");
tzset();
time(&td);
Yes, I see that, although I don't see documentation for the tzset()
function (maybe it is somewhere else).
Quote
You might also look into using the Win32 API (in Win32.hlp)
GetLocalTime()
GetTimeZoneInformation()
Since the same program I used here to test the strftime worked when
compiling with VS (I don't know the version number),
is possible that there compiler has a slightly different implementation
of the tzset function, that uses the Win32 API to get the TZ information
?
I don't know.
Any way, I'll keep checking (please read my comment on the VIM editor in
my reply to Alan).
Regards,
Jonathan Orlev
"Bob Gonder" < XXXX@XXXXX.COM >wrote in message
Quote
Jonathan Orlev wrote:

>tzset();

The help example for tzset (in BCB5.HLP) shows setting the environment
variable:

time_t td;
putenv("TZ=PST8PDT");
tzset();
time(&td);

You might also look into using the Win32 API (in Win32.hlp)
GetLocalTime()
GetTimeZoneInformation()


 

Re:Time zone returned empty from the function 'strftime' in BCC32 command-line compiler

Jonathan Orlev wrote:
Quote
Yes, I see that, although I don't see documentation for the tzset()
function (maybe it is somewhere else).
msdn.microsoft.com/library/default.asp
 

Re:Time zone returned empty from the function 'strftime' in BCC32 command-line compiler

hello Bob,
Well,
From the documentation in the link you specified:
"
If the TZ value is not set, _tzset attempts to use the time zone
information specified by the operating system.
"
It seems that under BCC32, the value is not being read from the
operating system, while with VS is does.
I don't know the reason, but I am not sure that there is some kind fault
in the compiler.
Maybe there is a way to point it to the right DLL ?
I don't know, I don't know how these things work.
Any way, there are more chekings I am doing, and I'll keep you (and the
group) posted.
Regards,
Jonathan Orlev
"Bob Gonder" < XXXX@XXXXX.COM >wrote in message
Quote
Jonathan Orlev wrote:

>Yes, I see that, although I don't see documentation for the tzset()
>function (maybe it is somewhere else).

msdn.microsoft.com/library/default.asp