cmsutil.c
/*-------------------------------------------------------------- CMSUTIL.C -- CMS General utility routines. L. R. Erickson, Apr. 1994 ----------------------------------------------------------------*/ #include <windows.h> #include <stdlib.h> #include <time.h> #include "cms.h" /*-------------------------------------------------------------- Time Stuff ---------------------------------------------------------------*/ // File level time globals static char sDate [2], sTime [2], sAMPM [2][5] ; static int iDate, iTime ; /* void UpdateCMSTime (HWND hwnd) { static char cTimeStr[60] = "CMS Cal Control " ; //short nLength ; // nLength = wsprintf (cTimeStr, " Test Text ") ; wsprintf (cTimeStr + 17, "%s", (LPSTR) " Test Text ") ; SetWindowText (hwnd, cTimeStr) ; } */ void UpdateCMSTime (HWND hwnd) { static char szWday[] = "Sun\0Mon\0Tue\0Wed\0Thu\0Fri\0Sat" ; char cTimeStr[60] = "CMS Control " ; short nLength = 13 ; struct tm *datetime ; time_t lTime ; time (&lTime) ; datetime = localtime (&lTime) ; nLength += wsprintf (cTimeStr + nLength, " %s %d%s%02d%s%02d ", (LPSTR) szWday + 4 * WDAY, iDate == 1 ? MDAY : iDate == 2 ? YEAR : MONTH, (LPSTR) sDate, iDate == 1 ? MONTH : iDate == 2 ? MONTH : MDAY, (LPSTR) sDate, iDate == 1 ? YEAR : iDate == 2 ? MDAY : YEAR) ; // if (iTime == 1) nLength += wsprintf (cTimeStr + nLength, " %02d%s%02d%s%02d ", HOUR, (LPSTR) sTime, MIN, (LPSTR) sTime, SEC) ; // else // nLength += wsprintf (cTimeStr + nLength, " %d%s%02d%s%02d %s ", // (HOUR % 12) ? (HOUR % 12) : 12, // (LPSTR) sTime, MIN, (LPSTR) sTime, SEC, // (LPSTR) sAMPM [HOUR / 12]) ; SetWindowText (hwnd, cTimeStr) ; } void SetInternational (void) { static char cName [] = "intl" ; iDate = GetProfileInt (cName, "iDate", 0) ; iTime = GetProfileInt (cName, "iTime", 0) ; GetProfileString (cName, "sDate", "/", sDate, 2) ; GetProfileString (cName, "sTime", ":", sTime, 2) ; GetProfileString (cName, "s1159", "AM", sAMPM [0], 5) ; GetProfileString (cName, "s2359", "PM", sAMPM [1], 5) ; } /* ----------------- End of time stuff -------------------------*/