static BOOL SearchDates_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) { wchar_t szDFormat[128], szTFormat[128]; g_hSearchDates = hwnd; CenterWindow(hwnd, FALSE); m_hListResults = GetDlgItem(hwnd, IDC_LST_RESULTS); PrepareResultsList(hwnd); ApplySearchDatesLanguage(hwnd); ParseDateFormat(g_DTFormats.DateFormat, szDFormat, szTFormat); SendDlgItemMessageW(hwnd, IDC_CAL_SEARCH_FROM, DTM_SETFORMATW, 0, (LPARAM)szDFormat); SendDlgItemMessageW(hwnd, IDC_CAL_SEARCH_TO, DTM_SETFORMATW, 0, (LPARAM)szDFormat); return FALSE; }
// Convert an ISC_QUAD to Cobol date format. Used to convert date fields after // calling other isc _ routines EXPORT RM_ENTRY(rmc_ctod) { struct tm tim; date_fmt fmt; char stemp[10]; ClearParamPool(); const ISC_UCHAR* fmtString = CobolToString(&arg_vector[2]); ISC_UCHAR* dt = AllocStringPool((int)strlen((char *)fmtString) + 1); memset(dt, 0, strlen((char *)fmtString) + 1); isc_decode_date((ISC_QUAD *)arg_vector[1].a_address, &tim); ParseDateFormat(fmtString, &fmt); if (fmt.yr_start != -1) { sprintf(stemp, "%*.*d", fmt.yr_len, fmt.yr_len, tim.tm_year + 1900); memmove(dt + fmt.yr_start, stemp, fmt.yr_len); } if (fmt.mon_start != -1) { sprintf(stemp, "%2.2d", tim.tm_mon + 1); memmove(dt + fmt.mon_start, stemp, 2); } if (fmt.day_start != -1) { sprintf(stemp, "%2.2d", tim.tm_mday); memmove(dt + fmt.day_start, stemp, 2); } if (fmt.hr_start != -1) { sprintf(stemp, "%2.2d", tim.tm_hour); memmove(dt + fmt.hr_start, stemp, 2); } if (fmt.min_start != -1) { sprintf(stemp, "%2.2d", tim.tm_min); memmove(dt + fmt.min_start, stemp, 2); } if (fmt.sec_start != -1) { sprintf(stemp, "%2.2d", tim.tm_sec); memmove(dt + fmt.sec_start, stemp, 2); } StringToCobol(&arg_vector[0], dt); return (0); }
// Convert a Cobol date field to ISC_QUAD format. Used to convert date fields // before calling other isc_ routines. EXPORT RM_ENTRY(rmc_dtoc) { char stemp[10]; struct tm tim; date_fmt fmt; ClearParamPool(); const int dtlen = arg_vector[1].a_length; const ISC_UCHAR* dt = arg_vector[1].a_address; const ISC_UCHAR* fmtString = CobolToString(&arg_vector[2]); ParseDateFormat(fmtString, &fmt); memset(&tim, 0, sizeof(tim)); if ((fmt.yr_start != -1) && (fmt.yr_start < dtlen)) { memset(stemp, 0, sizeof(stemp)); memmove(stemp, dt + fmt.yr_start, fmt.yr_len); tim.tm_year = atoi(stemp); // If the year is supplied as 4 digits, no problem just decerement by 1900 // to keep isc_encode_date happy. If 2 digits, assume date > 2000 and // add 100 to keep isc_encode_date happy. if (fmt.yr_len > 2) tim.tm_year -= 1900; else tim.tm_year += 100; } if ((fmt.mon_start != -1) && (fmt.mon_start < dtlen)) { memset(stemp, 0, sizeof(stemp)); memmove(stemp, dt + fmt.mon_start, 2); tim.tm_mon = atoi(stemp) - 1; } if ((fmt.day_start != -1) && (fmt.day_start < dtlen)) { memset(stemp, 0, sizeof(stemp)); memmove(stemp, dt + fmt.day_start, 2); tim.tm_mday = atoi(stemp); } if ((fmt.hr_start != -1) && (fmt.hr_start < dtlen)) { memset(stemp, 0, sizeof(stemp)); memmove(stemp, dt + fmt.hr_start, 2); tim.tm_hour = atoi(stemp); } if ((fmt.min_start != -1) && (fmt.min_start < dtlen)) { memset(stemp, 0, sizeof(stemp)); memmove(stemp, dt + fmt.min_start, 2); tim.tm_min = atoi(stemp); } if ((fmt.sec_start != -1) && (fmt.sec_start < dtlen)) { memset(stemp, 0, sizeof(stemp)); memmove(stemp, dt + fmt.sec_start, 2); tim.tm_sec = atoi(stemp); } isc_encode_date(&tim, (ISC_QUAD *)arg_vector[0].a_address); return (0); }