Re: [gtk-list] date entry




Kevin Handy <kth@srv.net> writes:
> I want to pass it a date that I get in the format 'YYYYMMDD'.
> There are some date functions in glib (g_date_xxxx) that
> manipulate dates, but it doesn't have any funtion to return
> the value in a time_t format, or operate on a time_t value.
> 

To operate on a time_t just call g_date_set_time() to convert to
GDate, then do your operations. To get back to time_t I guess you have
to call g_date_to_struct_tm() them use mktime(), which kind of sucks.
The conversion is lame in the first place because you have to pick an
arbitrary time during the day when you go from GDate to time_t.

> Shouldn't the g_date functions be able to handle the date
> formats used by the gnome functions, or should the gnome
> functions be modified to handle the g_date structure?
>

I think the date entry should take a GDate, yes. It might be nice to 
fix this in the development version of gnome-libs. If you could file a
bug report on bugs.gnome.org (or even submit a patch :-) it would be
helpful.

Actually the problem is that date entry is actually a time entry, I
think - thus GDate doesn't work.

BTW we had a heated RHAD Labs argument one day about whether GDate
should just use a time_t type thing internally and represent a time
rather than a day (with a larger range, avoiding the < 1970 and > 2038
problem). Pretty much everyone but me thinks it should. So a new time
thingy may go in to glib someday.

Havoc

 



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