RES: [freetds] Locale specific problem

Simon simon at
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:
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...

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

	On Tue, 10 Aug 2004 <simon at> 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: 
	     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. 
	#include <stdio.h>
	#include <time.h>
	        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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 7058 bytes
Desc: not available
Url : 

More information about the FreeTDS mailing list