public static string DateToDateString(wcServerAPI.FileTime ft, bool DoTime) { string tempDateToDateString = null; wcServerAPI.SYSTEMTIME s = new wcServerAPI.SYSTEMTIME(); string DateStr = ""; int nResult = 0; if (GetLocaleInfo(GetThreadLocale(), LOCALE_SSHORTDATE, DateMask, 25) == 0) { DateMask = "MM/dd/yyyy"; } if (GetLocaleInfo(GetThreadLocale(), LOCALE_SDATE, DateSeparator, 25) == 0) { DateSeparator = "/"; } tempDateToDateString = ""; if (wcServerAPI.FileTimeToSystemTime(ref ft, ref s) == 0) { tempDateToDateString = ""; } else { nResult = GetDateFormat(GetThreadLocale(), 0, ref s, DateMask.Trim(), DateStr, 25); tempDateToDateString = DateStr; string myTempString = null; if (tempDateToDateString.Trim() == "") { myTempString = s.wMonth.ToString("0#") + DateSeparator.Trim() + s.wDay.ToString("0#") + DateSeparator.Trim() + s.wYear.ToString("####"); if (DoTime) { myTempString = myTempString + " " + s.wHour.ToString("0#") + ":" + s.wMinute.ToString("0#"); } if (Microsoft.VisualBasic.Information.IsDate(myTempString)) { tempDateToDateString = myTempString; } else { tempDateToDateString = System.DateTime.Now.ToString("d") + " " + System.DateTime.Now.ToString("t"); } } else { myTempString = tempDateToDateString; if (DoTime) { myTempString = tempDateToDateString + " " + s.wHour.ToString("0#") + ":" + s.wMinute.ToString("0#"); } if (Microsoft.VisualBasic.Information.IsDate(myTempString)) { tempDateToDateString = myTempString; } else { tempDateToDateString = System.DateTime.Now.ToString("d") + " " + System.DateTime.Now.ToString("t"); } } } return tempDateToDateString; }
public static string DateToDateString(wcServerAPI.FileTime ft) { return DateToDateString(ft, false); }