Re: [gnome-db] gdafield &dbgrid & timestamp



On Fri, 2001-12-21 at 16:54, Juan Andrés Bentancour wrote:
> Hi friends...
> 
> I have a postgres table like this:
> 
> CREATE TABLE "test" ( "timedate" timestamp NOT NULL);
> 
> INSERT INTO test VALUES ('25/12/2001');
> INSERT INTO test VALUES ('31/12/2001');
> INSERT INTO test VALUES ('31/12/2001 23:59:59');
> 
> and this source code:
> 
> GdaRecordset *rs = gda_recordset_new ();
> time_t t;
> gda_recordset_set_connection (rs, cnc);
> gda_recordset_open_txt (rs, "select * from test",
> 			  GDA_OPEN_FWDONLY, GDA_LOCK_PESSIMISTIC, 0);
> gda_recordset_move_first (rs);
> while (!gda_recordset_eof (rs))
> {
>   t = gda_field_get_timestamp_value (gda_recordset_field_idx (rs, 0));
>   g_print ("timedate: %s\n",str_timedate_from_time_t(t)); 
>   gda_recordset_move_next(rs);
> }
> 
> char * 
> str_timedate_from_time_t (time_t t)
> {	
> 	struct tm *tm;
> 	static char isotime [40];
> 
> 	tm = localtime (&t);
> 	strftime (isotime, sizeof (isotime)-1, "%d/%m/%Y-%H:%M:%S", tm);
> 	return isotime;
> }lmail.com.ar
> 
> 
> the output is:
> 
> timedate: 31/12/1969-20:59:59
> timedate: 31/12/1969-20:59:59
> timedate: 31/12/1969-20:59:59
> 
> 
> with a dbgrid:
> ( snapshot.jpg )
> 
> what is the problem ???
> 
hmm, this looks like the postgres provider is not managing that data
type. I'll have a look at it next week, and hope to have a patch for it.

cheers
-- 
Rodrigo Moya <rodrigo gnome-db org> - <rodrigo ximian com>
http://www.gnome-db.org/ - http://www.ximian.com/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]