gnome-date-entry widget add-ons
- From: Kevin Handy <kth srv net>
- To: gnome-devel-list gnome org
- Subject: gnome-date-entry widget add-ons
- Date: Wed, 08 Mar 2000 01:04:41 -0700
Here is a couple of functions for the gnome_date_entry widget to
make it a little easier to use with different date sources.
I have created two "_new" functions to handle 'struct tm*' and
'g_date' sources, and two functions to get the date back out
in those two formats.
They are written so that none of the current functionality is
changed. It just calls the current 'new' and 'get' functions
and converts the date into the corresponding format.
Are these useful enough for inclusion in gnome? Should the
parameters be changed on any of the routines?
At some point, if they are accepted into gnome, they should
probably be modified to grab the internal structures more
directly to bypass any 2038 year problems with time_t.
This first try is to see how useful they would be.
#include <gnome.h>
#include <time.h>
#include "gnome-dateedit-2.h"
GtkWidget *
gnome_date_edit_new_tm (struct tm *the_time, int show_time, int use_24_format)
{
time_t tdate;
tdate = mktime(the_time);
return gnome_date_edit_new(tdate, show_time, use_24_format);
}
GtkWidget *
gnome_date_edit_new_gdate (GDate* the_time, int show_time, int use_24_format)
{
struct tm tmdate;
time_t tdate;
g_date_to_struct_tm(the_time, &tmdate);
tdate = mktime(&tmdate);
return gnome_date_edit_new(tdate, show_time, use_24_format);
}
struct tm *
gnome_date_edit_get_date_tm (GnomeDateEdit *gde)
{
time_t rt = gnome_date_edit_get_date(gde);
struct tm *rtm = localtime(&rt);
return rtm;
}
GDate *
gnome_date_edit_get_date_gdate (GnomeDateEdit *gde)
{
time_t rt = gnome_date_edit_get_date(gde);
struct tm *rtm = localtime(&rt);
GDate* dt;
return dt;
}
#ifndef __GNOME_DATEEDIT2_H__
#define __GNOME_DATEEDIT2_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
GtkWidget *gnome_date_edit_new_tm (struct tm *the_time, int show_time, int use_24_format);
GtkWidget *gnome_date_edit_new_gdate (GDate* the_time, int show_time, int use_24_format);
struct tm *gnome_date_edit_get_date_tm (GnomeDateEdit *gde);
GDate *gnome_date_edit_get_date_gdate (GnomeDateEdit *gde);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]