RES: [freetds] Locale specific problem
Simon
simon at magazineluiza.com.br
Thu Aug 12 08:34:41 EDT 2004
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 7058 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/freetds/attachments/20040812/2dc978bb/attachment.bin
More information about the FreeTDS
mailing list