Skip to Content.
Sympa Menu

freetds - Re: [freetds] Locale specific problem

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT schemamania.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Locale specific problem
  • Date: Wed, 11 Aug 2004 18:31:06 -0400

On Tue, 10 Aug 2004 <simon AT magazineluiza.com.br> wrote:
>
> I believe I have a bug in freetds's date-time formatting. The locale on
> my box is ...;LC_TIME=pt_BR;...
>
> 12:00 is shown as 12:00 and 12:00PM is shown as 12:00... i.e. I can´t
> differentiate between AM and PM. For this locale, it would be normally
> shown as 00:00-23:59.

Hi Simon,

Welcome to the project.

FreeTDS uses strftime(3) to format date strings:

size_t
strftime(char * restrict buf, size_t maxsize,
const char * restrict format,
const struct tm * restrict timeptr);

The format string is taken from locales.conf. There is a built-in default
if its not found, one for each client library (because historically each
has had its own default format). Are you perhaps using ODBC? Cf. 4
odbc.c, line 1034. Else grep for date_fmt.

Probably all you need to do is add a section for pt_BR to locales.conf.
If that doesn't do the trick, please show the output of the attached
little program.

Regards,

--jkl

#include <stdio.h>
#include <time.h>

int
main()
{
char buf[80];

time_t clock = time(NULL);

struct tm *ptm = localtime(&clock);

ptm->tm_hour = ptm->tm_min = ptm->tm_sec = 0;

strftime( buf, sizeof(buf), "%b %d %Y %I:%M%p", ptm );
puts( buf );

ptm->tm_hour = 12;

strftime( buf, sizeof(buf), "%b %d %Y %I:%M%p", ptm );
puts( buf );

return 0;
}






Archive powered by MHonArc 2.6.24.

Top of Page