Re: dateformat



There is still problem because sometime I don't get date with same lenght string.
I get 7/8/2005 or 12/12/2005 or 7/12/2005.

I get this date with this code :

void
on_btn_get_date_clicked                (GtkButton       *button,
                                        gpointer         user_data)
{
 GtkWidget *calen,*tentry1;
 gint gyear,gmonth,gday;
 char *str_day,*str_month,*str_year,str_date[16];
 
  calen = lookup_widget(GTK_WIDGET(button),"calendar1");
  
  gtk_calendar_get_date(calen,&gyear,&gmonth,&gday);

  str_year = g_strdup_printf("%i", gyear); 
  str_month = g_strdup_printf("%i", gmonth+1); 
  str_day = g_strdup_printf("%i", gday); 
  
  strcpy(str_date,str_day); 
  strcat(str_date,"/");  
  strcat(str_date,str_month);   
  strcat(str_date,"/");    
  strcat(str_date,str_year);
  
  gtk_entry_set_text(GTK_ENTRY(lookup_widget(frm_purchase, 
                               "entry_date_purchase")), str_date);
}

Then I fill to GTK list after that I want to save to mysql in yyyy/mm/dd.

On Wed, 9 Mar 2005 05:43:13 +0100 (CET)
stian nixia no wrote:

> > Is there dateformat function in gtk? I have date dd/mm/yyyy and I want
> to change to yyyy/yy/dd Mysql format.
> > thx
> 
> That would be plain playing
> 
> void convert(char *dst, const char *src)
> {
>  dst[0]=src[6];
>  dst[1]=src[7];
>  dst[2]=src[8];
>  dst[3]=src[9];
>  dst[4]='/';
>  dst[5]=src[3];
>  dst[6]=src[4];
>  dst[7]='/';
>  dst[8]=src[0];
>  dst[9]=src[1];
>  dst[10]=0;
> }
> 
> Stian
> 




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