comparison gtk/dw.c @ 165:d03716228b7f

Use strftime to display time and date on Windows and unix.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 18 Nov 2002 15:24:01 +0000
parents d35771f70bdd
children 0b3debaa9c6c
comparison
equal deleted inserted replaced
164:d35771f70bdd 165:d03716228b7f
27 /* These are used for resource management */ 27 /* These are used for resource management */
28 #if defined(DW_RESOURCES) && !defined(BUILD_DLL) 28 #if defined(DW_RESOURCES) && !defined(BUILD_DLL)
29 extern DWResources _resources; 29 extern DWResources _resources;
30 #endif 30 #endif
31 31
32 char monthlist[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
33 "Sep", "Oct", "Nov", "Dec" };
34 GdkColor _colors[] = 32 GdkColor _colors[] =
35 { 33 {
36 { 0, 0x0000, 0x0000, 0x0000 }, /* 0 black */ 34 { 0, 0x0000, 0x0000, 0x0000 }, /* 0 black */
37 { 0, 0xbbbb, 0x0000, 0x0000 }, /* 1 red */ 35 { 0, 0xbbbb, 0x0000, 0x0000 }, /* 1 red */
38 { 0, 0x0000, 0xbbbb, 0x0000 }, /* 2 green */ 36 { 0, 0x0000, 0xbbbb, 0x0000 }, /* 2 green */
4117 4115
4118 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); 4116 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
4119 } 4117 }
4120 else if(flag & DW_CFA_DATE) 4118 else if(flag & DW_CFA_DATE)
4121 { 4119 {
4122 CDATE fdate = *((CDATE *)data); 4120 struct tm curtm;
4123 4121 CDATE cdate = *((CDATE *)data);
4124 if(/*fdate.month > -1 &&*/ fdate.month < 12 && fdate.day > 0 && fdate.year > 0) 4122
4125 sprintf(textbuffer, "%s %d, %d", monthlist[fdate.month], fdate.day, fdate.year); 4123 curtm.tm_mday = cdate.day;
4126 else 4124 curtm.tm_mon = cdate.month - 1;
4127 strcpy(textbuffer, ""); 4125 curtm.tm_year = cdate.year - 1900;
4126
4127 strftime(textbuffer, 100, "%x", &curtm);
4128 4128
4129 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); 4129 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
4130 } 4130 }
4131 else if(flag & DW_CFA_TIME) 4131 else if(flag & DW_CFA_TIME)
4132 { 4132 {
4133 CTIME ftime = *((CTIME *)data); 4133 struct tm curtm;
4134 4134 CTIME ctime = *((CTIME *)data);
4135 if(ftime.hours > 12) 4135
4136 sprintf(textbuffer, "%d:%s%dpm", ftime.hours - 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); 4136 curtm.tm_hour = ctime.hours;
4137 else 4137 curtm.tm_min = ctime.minutes;
4138 sprintf(textbuffer, "%d:%s%dam", ftime.hours ? ftime.hours : 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); 4138 curtm.tm_sec = ctime.seconds;
4139
4140 strftime(textbuffer, 100, "%X", &curtm);
4141
4139 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); 4142 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
4140 } 4143 }
4141 DW_MUTEX_UNLOCK; 4144 DW_MUTEX_UNLOCK;
4142 } 4145 }
4143 4146