comparison win/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 c555d06b6c93
children 0b3debaa9c6c
comparison
equal deleted inserted replaced
164:d35771f70bdd 165:d03716228b7f
30 #define IS_IE5PLUS (dwComctlVer >= PACKVERSION(5,80)) 30 #define IS_IE5PLUS (dwComctlVer >= PACKVERSION(5,80))
31 31
32 #ifndef MIN 32 #ifndef MIN
33 #define MIN(a, b) (((a) < (b)) ? (a) : (b)) 33 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
34 #endif 34 #endif
35
36 char monthlist[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
37 "Sep", "Oct", "Nov", "Dec" };
38 35
39 int main(int argc, char *argv[]); 36 int main(int argc, char *argv[]);
40 37
41 #define ICON_INDEX_LIMIT 200 38 #define ICON_INDEX_LIMIT 200
42 HICON lookup[200]; 39 HICON lookup[200];
5728 lvi.pszText = textbuffer; 5725 lvi.pszText = textbuffer;
5729 lvi.cchTextMax = strlen(textbuffer); 5726 lvi.cchTextMax = strlen(textbuffer);
5730 } 5727 }
5731 else if(flags[column] & DW_CFA_DATE) 5728 else if(flags[column] & DW_CFA_DATE)
5732 { 5729 {
5733 CDATE fdate = *((CDATE *)data); 5730 struct tm curtm;
5734 5731 CDATE cdate = *((CDATE *)data);
5735 if(fdate.month > -1 && fdate.month < 12 && fdate.day > 0 && fdate.year > 0) 5732
5736 sprintf(textbuffer, "%s %d, %d", monthlist[fdate.month], fdate.day, fdate.year); 5733 curtm.tm_mday = cdate.day;
5737 else 5734 curtm.tm_mon = cdate.month - 1;
5738 strcpy(textbuffer, ""); 5735 curtm.tm_year = cdate.year - 1900;
5736
5737 strftime(textbuffer, 100, "%x", &curtm);
5738
5739 lvi.pszText = textbuffer; 5739 lvi.pszText = textbuffer;
5740 lvi.cchTextMax = strlen(textbuffer); 5740 lvi.cchTextMax = strlen(textbuffer);
5741 } 5741 }
5742 else if(flags[column] & DW_CFA_TIME) 5742 else if(flags[column] & DW_CFA_TIME)
5743 { 5743 {
5744 CTIME ftime = *((CTIME *)data); 5744 struct tm curtm;
5745 5745 CTIME ctime = *((CTIME *)data);
5746 if(ftime.hours > 12) 5746
5747 sprintf(textbuffer, "%d:%s%dpm", ftime.hours - 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); 5747 curtm.tm_hour = ctime.hours;
5748 else 5748 curtm.tm_min = ctime.minutes;
5749 sprintf(textbuffer, "%d:%s%dam", ftime.hours ? ftime.hours : 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); 5749 curtm.tm_sec = ctime.seconds;
5750
5751 strftime(textbuffer, 100, "%X", &curtm);
5752
5750 lvi.pszText = textbuffer; 5753 lvi.pszText = textbuffer;
5751 lvi.cchTextMax = strlen(textbuffer); 5754 lvi.cchTextMax = strlen(textbuffer);
5752 } 5755 }
5753 5756
5754 ListView_SetItem(handle, &lvi); 5757 ListView_SetItem(handle, &lvi);