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
> 
as you can see, this is almost the same as 0/0/00 (unix time starts in
1/1/1970). So, I think the problem is that the provider (in this case,
gda-postgres) is not converting correctly the timestamp fields.

In fact, in
libgda/providers/gda-postgres-server/gda-postgres-recordset.c, in
fill_field_values function:

///////////////////////////////////////////////////////////

case GDA_TypeDbTimestamp:       /* FIXME */
                      /* binded to datetime, timestamp, abstime,
interval/timespan,
                                   tinterval, reltime */
//////////////////////////////////////////////////////////

it seems there is something wrong in that part of the code. Vivien, any
idea what the problem is?

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]