Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* strftime problems?
@ 1998-01-30  5:00 Jean-Claude Magras
  1998-02-11  5:00 ` Joe Mario
  0 siblings, 1 reply; 2+ messages in thread
From: Jean-Claude Magras @ 1998-01-30  5:00 UTC (permalink / raw)



Greetings,

I am contributing to a known freeware project and I am having trouble
with strftime (on Digital UNix 3.2).. I use the "%T: meaning HH:MM:SS
is the output string. I have checked the contents of the struct tm
I pass in and they seem valid (that is the mt_hour/mt_min/mt_sec fields
seem valid but strfime() usually reports "00:00:00". It sometimes puts
an asterisk or slash in the hours field or occassionally a 12 or 3
but its never correct.
I do call tzset().

Thanks in advance.

Any help appreciated,

J.C. Magras
-- 
 Unix Software Engineer looking for C++/UNIX/Motif/Perl/Tk/Flex
 Software Engineering position **NOW**. Currently in Austin at
 (512) 672-5778/magrasjc@texas.net. have Answering machine.



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: strftime problems?
  1998-01-30  5:00 strftime problems? Jean-Claude Magras
@ 1998-02-11  5:00 ` Joe Mario
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Mario @ 1998-02-11  5:00 UTC (permalink / raw)
  To: Jean-Claude Magras


Jean-Claude Magras wrote:
> 
> I am contributing to a known freeware project and I am having trouble
> with strftime (on Digital UNix 3.2).. I use the "%T: meaning HH:MM:SS
> is the output string. I have checked the contents of the struct tm
> I pass in and they seem valid (that is the mt_hour/mt_min/mt_sec
> fields seem valid but strfime() usually reports "00:00:00". It
> sometimes puts an asterisk or slash in the hours field or
> occassionally a 12 or 3 but its never correct.

Here's some input from a strftime maintainer:

 I can't be sure what the problem is from this limited
description. I'm assuming he mis-typed the tm field names
(tm_hour, tm_min, tm_sec) in this message, but not in the
program itself. If he wants to use %T as the output format,
I assume his code looks something like this:

   . . .
   char dtbuf[MAXSIZE];
   time_t clock;
   struct tm *timeptr;
   
   clock = time ((long*)NULL);
   timeptr = localtime(&clock);
   strftime(dtbuf, MAXSIZE, "%T", timeptr);
   printf("%s\n", dtbuf);

Of course, as an i18n person, I should point out this is
not a good way to code things. He should get the output
format from a locale. I looked at the Digital locales, and
virtually all of them use the equivalent of %T for their
time format (t_fmt). That means he needs to include <locale.h>
and <langinfo.h>, add a call to setlocale() at the beginning
of the program, and call strftime() this way:

strftime(dtbuf, MAXSIZE, nl_langinfo(T_FMT), timeptr);

Then it should work.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-02-11  5:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-01-30  5:00 strftime problems? Jean-Claude Magras
1998-02-11  5:00 ` Joe Mario

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox