Skip to Content.
Sympa Menu

freetds - RES: [freetds] Locale specific problem

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Simon" <simon AT magazineluiza.com.br>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: RES: [freetds] Locale specific problem
  • Date: Thu, 12 Aug 2004 09:34:41 -0300

Hi James!

The output from the program correctly distinguishes 12AM and 12PM:

Aug 12 2004 12:00AM
Aug 12 2004 12:00PM

I did some experimenting, and would suggest adding this to the locale.conf:

[pt_BR]
date format = %d/%m/%Y %H:%M

I wonder why the default wouldn't be "%Y-%m-%d %H:%M". This is how it shows
up in my Query Analyzer, and would make the output sortable without having to
do a convert(varchar...

Simon

-----Mensagem original-----
De: freetds-bounces AT lists.ibiblio.org em nome de James K. Lowden
Enviada: qua 11/8/2004 19:31
Para: FreeTDS Development Group
Cc:
Assunto: Re: [freetds] Locale specific problem



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;
}


_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds


<<winmail.dat>>



  • RES: [freetds] Locale specific problem, Simon, 08/12/2004

Archive powered by MHonArc 2.6.24.

Top of Page