本文整理汇总了C++中GetDateFormat函数的典型用法代码示例。如果您正苦于以下问题:C++ GetDateFormat函数的具体用法?C++ GetDateFormat怎么用?C++ GetDateFormat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetDateFormat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveSessionDate
int SaveSessionDate()
{
if (session_list[0] != 0) {
int TimeSize = GetTimeFormat(LOCALE_USER_DEFAULT, 0/*TIME_NOSECONDS*/, NULL, NULL, NULL, 0);
TCHAR *szTimeBuf = (TCHAR*)mir_alloc((TimeSize + 1)*sizeof(TCHAR));
GetTimeFormat(LOCALE_USER_DEFAULT, 0/*TIME_NOSECONDS*/, NULL, NULL, szTimeBuf, TimeSize);
int DateSize = GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, NULL, 0);
TCHAR *szDateBuf = (TCHAR*)mir_alloc((DateSize + 1)*sizeof(TCHAR));
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, szDateBuf, DateSize);
int lenn = (DateSize + TimeSize + 5);
TCHAR *szSessionTime = (TCHAR*)mir_alloc(lenn*sizeof(TCHAR));
mir_sntprintf(szSessionTime, lenn, _T("%s - %s"), szTimeBuf, szDateBuf);
char szSetting[256];
mir_snprintf(szSetting, "%s_%d", "SessionDate", 0);
TCHAR *ptszSaveSessionDate = db_get_tsa(NULL, MODNAME, szSetting);
db_set_ts(NULL, MODNAME, szSetting, szSessionTime);
mir_free(szSessionTime);
if (ptszSaveSessionDate)
ResaveSettings("SessionDate", 1, g_ses_limit, ptszSaveSessionDate);
if (szTimeBuf)
mir_free(szTimeBuf);
if (szDateBuf)
mir_free(szDateBuf);
}
if (g_bCrashRecovery)
db_set_b(NULL, MODNAME, "lastSaveCompleted", 1);
return 0;
}
示例2: MAKELCID
void CGitPropertyPage::Time64ToTimeString(__time64_t time, TCHAR * buf, size_t buflen) const
{
struct tm newtime;
SYSTEMTIME systime;
LCID locale = LOCALE_USER_DEFAULT;
if (!CRegDWORD(_T("Software\\TortoiseGit\\UseSystemLocaleForDates"), TRUE))
locale = MAKELCID((WORD)CRegStdDWORD(_T("Software\\TortoiseGit\\LanguageID"), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)), SORT_DEFAULT);
*buf = '\0';
if (time)
{
TCHAR timebuf[MAX_STRING_LENGTH] = { 0 };
TCHAR datebuf[MAX_STRING_LENGTH] = { 0 };
_localtime64_s(&newtime, &time);
systime.wDay = (WORD)newtime.tm_mday;
systime.wDayOfWeek = (WORD)newtime.tm_wday;
systime.wHour = (WORD)newtime.tm_hour;
systime.wMilliseconds = 0;
systime.wMinute = (WORD)newtime.tm_min;
systime.wMonth = (WORD)newtime.tm_mon+1;
systime.wSecond = (WORD)newtime.tm_sec;
systime.wYear = (WORD)newtime.tm_year+1900;
if (CRegStdDWORD(_T("Software\\TortoiseGit\\LogDateFormat")) == 1)
GetDateFormat(locale, DATE_SHORTDATE, &systime, NULL, datebuf, MAX_STRING_LENGTH);
else
GetDateFormat(locale, DATE_LONGDATE, &systime, NULL, datebuf, MAX_STRING_LENGTH);
GetTimeFormat(locale, 0, &systime, NULL, timebuf, MAX_STRING_LENGTH);
*buf = '\0';
_tcsncat_s(buf, buflen, datebuf, MAX_STRING_LENGTH-1);
_tcsncat_s(buf, buflen, _T(" "), MAX_STRING_LENGTH-1);
_tcsncat_s(buf, buflen, timebuf, MAX_STRING_LENGTH-1);
}
}
示例3: ChangeTip
void ChangeTip(NOTIFYICONDATA* nid, SYSTEMTIME* time) {
TCHAR *buf, *datef = _T("dddd yyyy.MM.dd");
HANDLE heap = GetProcessHeap();
size_t n;
n = GetDateFormat(LOCALE_USER_DEFAULT, 0, time, datef, NULL, 0);
buf = (TCHAR*)HeapAlloc(heap, HEAP_ZERO_MEMORY, n * sizeof(TCHAR));
GetDateFormat(LOCALE_USER_DEFAULT, 0, time, datef, buf, n);
_stprintf_s(nid->szTip, 64, _T("%s %02d:%02d"), buf, time->wHour, time->wMinute);
HeapFree(heap, 0, buf);
}
示例4: parseLastSeenDate
static TCHAR* parseLastSeenDate(ARGUMENTSINFO *ai)
{
if (ai->argc <= 1)
return NULL;
MCONTACT hContact = NULL;
CONTACTSINFO ci = { 0 };
ci.cbSize = sizeof(ci);
ci.tszContact = ai->targv[1];
ci.flags = 0xFFFFFFFF ^ (CI_TCHAR == 0 ? CI_UNICODE : 0);
int count = getContactFromString(&ci);
if (count == 1 && ci.hContacts != NULL) {
hContact = ci.hContacts[0];
mir_free(ci.hContacts);
}
else {
mir_free(ci.hContacts);
return NULL;
}
TCHAR *szFormat;
if (ai->argc == 2 || (ai->argc > 2 && mir_tstrlen(ai->targv[2]) == 0))
szFormat = NULL;
else
szFormat = ai->targv[2];
SYSTEMTIME lsTime = { 0 };
char *szModule = SEEN_MODULE;
lsTime.wYear = db_get_w(hContact, szModule, "Year", 0);
if (lsTime.wYear == 0)
return NULL;
lsTime.wMilliseconds = 0;
lsTime.wSecond = db_get_w(hContact, szModule, "Seconds", 0);
lsTime.wMinute = db_get_w(hContact, szModule, "Minutes", 0);
lsTime.wHour = db_get_w(hContact, szModule, "Hours", 0);
lsTime.wDay = db_get_w(hContact, szModule, "Day", 0);
lsTime.wDayOfWeek = db_get_w(hContact, szModule, "WeekDay", 0);
lsTime.wMonth = db_get_w(hContact, szModule, "Month", 0);
int len = GetDateFormat(LOCALE_USER_DEFAULT, 0, &lsTime, szFormat, NULL, 0);
TCHAR *res = (TCHAR*)mir_alloc((len + 1)*sizeof(TCHAR));
if (res == NULL)
return NULL;
if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &lsTime, szFormat, res, len) == 0) {
mir_free(res);
return NULL;
}
return res;
}
示例5: CDialog
ExportGSASnapshot::ExportGSASnapshot(CString filename, CString title, CWnd* pParent /*=NULL*/)
: CDialog(ExportGSASnapshot::IDD, pParent)
{
//{{AFX_DATA_INIT(ExportGSASnapshot)
m_desc = _T("");
m_notes = _T("");
m_title = _T("");
//}}AFX_DATA_INIT
m_title = title;
m_filename = filename;
char date[100];
char time[100];
GetDateFormat(LOCALE_USER_DEFAULT,
DATE_SHORTDATE,
NULL,
NULL,
date,
100);
GetTimeFormat(LOCALE_USER_DEFAULT,
0,
NULL,
NULL,
time,
100);
m_desc.Format("%s %s", date, time);
}
示例6: formatDate
wstring formatDate(StringBuffer& date) {
wstring dd(TEXT(""));
wchar_t* wdate = toWideChar(date);
if (wdate == NULL) {
return dd;
}
wchar_t data[80];
wchar_t formatDate[80];
int found = 0;
SYSTEMTIME timeDest;
swscanf_s(wdate, L"%4d%2d%2d", &timeDest.wYear, &timeDest.wMonth, &timeDest.wDay);
GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, data, 80);
dd = data;
if ((found = dd.find(TEXT("dddd, "))) != wstring::npos) {
dd.replace(found, 6, TEXT(""));
} else if ((found = dd.find(TEXT("dddd,"))) != wstring::npos) {
dd.replace(found, 5, TEXT(""));
}else if ((found = dd.find(TEXT("dddd"))) != wstring::npos) {
dd.replace(found, 4, TEXT(""));
}
trim(dd);
GetDateFormat(LOCALE_USER_DEFAULT, NULL, &timeDest, dd.c_str(), formatDate, 80);
dd = formatDate;
return dd;
}
示例7: edfheader_to_physical
void edfheader_to_physical(EDFHEADERStruct * from, EDFHEADER_PHYSICALStruct * to)
{
int len,t;
char * ch;
SYSTEMTIME st;
char actdate[10];
char acttime[10];
len=256+256*from->channels;
ch=(char *)to;
for(t=0;t<256;t++,ch++) *ch=' ';
GetSystemTime(&st); // gets current time
GetDateFormat(0, 0, &st, "dd.MM.yy" , actdate, 9);actdate[8]=0;
GetTimeFormat(0, 0, &st, "HH.mm.ss" , acttime, 9);acttime[8]=0;
strcpy(to->startdate,actdate);
strcpy(to->starttime,acttime);
strcpy(to->version,"0");
strcpy(to->patient,from->patient);
strcpy(to->recording,from->device);
sprintf(to->records,"%d",from->segments);
sprintf(to->duration,"%d",1);
sprintf(to->channels,"%d",from->channels);
sprintf(to->headerlength,"%d",len);
ch=(char *)to;
for(t=0;t<256;t++,ch++) if (*ch==0) *ch=' ';
to->end=0;
}
示例8: CallContextDayNote
BOOL CallContextDayNote(SYSTEMTIME Time, HWND hCalendar)
{
CStringArray arr;
arr.Add(_l("New reminder"));
arr.Add(_l("Add date to clipboard"));
int iSelection=SelectFromMenu(arr,0);
if(iSelection<0){
return 0;
}
if(iSelection==0){
return -1;
}
CString s="";
COleDateTime tm;//=COleDateTime(Time);
tm.SetDate(Time.wYear,Time.wMonth,Time.wDay);
if(strlen(szDateFormat)==0){
s=DateFormat(tm,FALSE);
}else{
SYSTEMTIME EventTime;
tm.GetAsSystemTime(EventTime);
char szTmp[1020]={0};
GetDateFormat(LOCALE_USER_DEFAULT,0,&EventTime,szDateFormat,szTmp,sizeof(szTmp));
s=szTmp;
}
BOOL bThroughGlobal=0;
USES_CONVERSION;
SetClipboardText(A2W(s),bThroughGlobal,0);
return 0;
};
示例9: GetTime
//////////////////////////////////////////////////////////////////////
// Methode : GetTime
// Resume : Return Time cache entry
// In : FILETIME ft : the cache entry
// Out : CString Time of the cache entry
//////////////////////////////////////////////////////////////////////
CString GetTime(FILETIME ft)
{
SYSTEMTIME st;
char szLocalDate[255];
char szLocalTime[255];
CString strtemp;
FileTimeToLocalFileTime( &ft, &ft );
FileTimeToSystemTime( &ft, &st );
GetDateFormat( LOCALE_USER_DEFAULT,
DATE_SHORTDATE,
&st,
NULL,
szLocalDate,
255 );
GetTimeFormat( LOCALE_USER_DEFAULT,
0,
&st,
NULL,
szLocalTime,
255 );
strtemp = szLocalDate;
strtemp += " | ";
strtemp += szLocalTime ;
return (strtemp);
}
示例10: os_ctimeW_r
/** \brief Translate calendar time into readable string representation
*
* Possible Results:
* - returns buf if buf != NULL
* - returns NULL if buf == NULL
*/
os_size_t
os_ctimeW_r(
os_timeW *t,
char *buf,
os_size_t bufsz)
{
os_size_t result = 0;
SYSTEMTIME systemTime;
FILETIME systemTimeSince1601;
DWORD64 dw64Time;
DWORD64 dw64MAXDWORD = MAXDWORD;
wchar_t format[32];
char *fstr;
/* Using win32 ctime here */
if (buf)
{
int iSizeOfBuffer;
dw64Time = (t->wt)/100;
systemTimeSince1601.dwHighDateTime = (dw64Time / (dw64MAXDWORD+1));
systemTimeSince1601.dwLowDateTime = (dw64Time % (dw64MAXDWORD+1));
FileTimeToSystemTime(&systemTimeSince1601, &systemTime);
/* Time is in UTC here */
GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &systemTime, L"yyyy'-'MM'-'dd'T'HH':'mm':'ss", format, 32);
/* convert wide str to multi byte str */
fstr = wce_wctomb(format);
result = snprintf(buf, bufsz, "%s", fstr);
os_free(fstr);
}
return result;
}
示例11: GetDateFormat
//**************************************************************************************************
b8 A2Date::ToStr(s8 *str)
{
if (!*(s32*)&date) return 0;
#ifdef _WIN32
SYSTEMTIME time;
time.wYear = date.y;
time.wMonth = date.m;
time.wDayOfWeek = 0;
time.wDay = date.d;
time.wHour = 0;
time.wMinute = 0;
time.wSecond = 0;
time.wMilliseconds = 0;
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &time, NULL, str, -1);
#else
// sprintf(str, "%i.%i.%i", date.y, date.m, date.d);
// sprintf(str, "%i.%i.%i", date.d, date.m, date.y % 100);
sprintf(str, "%i/%i/%i", date.m, date.d, date.y % 100);
#endif
return 1;
}
示例12: data_get_modified_string
/*
* data_get_modified_string - 更新日時文字列を取得
*/
BOOL data_get_modified_string(const DATA_INFO *di, TCHAR *ret)
{
SYSTEMTIME sys_time;
TCHAR str_day[BUF_SIZE], str_time[BUF_SIZE];
TCHAR *p;
if (di->type != TYPE_ITEM ||
(di->modified.dwLowDateTime == 0 && di->modified.dwHighDateTime == 0)) {
*ret = TEXT('\0');
return FALSE;
}
// ファイルタイムをシステムタイムに変換
if (FileTimeToSystemTime(&di->modified, &sys_time) == FALSE) {
*ret = TEXT('\0');
return FALSE;
}
// 日付文字列の取得
p = option.data_date_format;
if (p == NULL || *p == TEXT('\0')) {
p = NULL;
}
GetDateFormat(0, 0, &sys_time, p, str_day, BUF_SIZE - 1);
// 時間文字列の取得
p = option.data_time_format;
if (p == NULL || *p == TEXT('\0')) {
p = NULL;
}
GetTimeFormat(0, 0, &sys_time, p, str_time, BUF_SIZE - 1);
wsprintf(ret, TEXT("%s %s"), str_day, str_time);
return TRUE;
}
示例13: FiletimeAsString
CString FiletimeAsString(FILETIME filetime)
{
SYSTEMTIME sysTime;
if(0 == FileTimeToSystemTime(&filetime,&sysTime))
return _T("");
SYSTEMTIME localTime;
TIME_ZONE_INFORMATION tzi;
GetTimeZoneInformation(&tzi);
if (!SystemTimeToTzSpecificLocalTime(&tzi, &sysTime, &localTime))
return _T("");
CString sDate;
TCHAR szDateBuffer[20] = {0};
TCHAR szTimeBuffer[20] = {0};
if (0 == GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &localTime, NULL, szDateBuffer, 20) ||
0 == GetTimeFormat(LOCALE_USER_DEFAULT, 0, &localTime, NULL, szTimeBuffer, 20))
return _T("");
sDate.Format(_T("%s %s"), szDateBuffer, szTimeBuffer);
if(-1 != sDate.Find(_T("1601")))
return _T("");
return sDate;
}
示例14: MonthNameGenitiveToNumber
// Converts locale-specific month name to month number
// Only converts genitives
static WORD MonthNameGenitiveToNumber(LPCTSTR szStr, int * piMonthNameLength)
{
SYSTEMTIME stTemp = {0};
TCHAR szMonthName[80];
int nLength;
// Prepare the temporary SYSTEMTIME structure
// Note: The recommended way to get month name as genitive is to use GetDateFormat
// with "ddMMMM" and compare month name starting at second position
stTemp.wDay = 1;
stTemp.wYear = 2000;
// Go through all month names.
for(stTemp.wMonth = 1; stTemp.wMonth <= 13; stTemp.wMonth++)
{
// Get genitive of month name
nLength = GetDateFormat(LOCALE_USER_DEFAULT, 0, &stTemp, _T("ddMMMM"), szMonthName, _maxchars(szMonthName));
if(nLength < 3)
break;
// Compare the month name
if(!_tcsnicmp(szStr, &szMonthName[2], nLength - 3))
{
*piMonthNameLength = (nLength - 3);
return stTemp.wMonth;
}
}
// Month name genitive not recognized
return 0xFFFF;
}
示例15: BMT_GetBackupFileTime
// Gets the timestamp on the current backup file
std::wstring
BMT_GetBackupFileTime (void)
{
WIN32_FIND_DATA FindFileData;
HANDLE hFileBackup = FindFirstFile (std::wstring (bmt::XML::install_path + L"..\\..\\BMGame\\Config\\BmSystemSettings.bmt").c_str (), &FindFileData);
FindClose (hFileBackup);
FILETIME ftModified;
FileTimeToLocalFileTime (&FindFileData.ftLastWriteTime, &ftModified);
SYSTEMTIME stModified;
FileTimeToSystemTime (&ftModified, &stModified);
wchar_t wszFileTime [512];
GetDateFormat (LOCALE_CUSTOM_UI_DEFAULT, DATE_AUTOLAYOUT, &stModified, NULL, wszFileTime, 512);
std::wstring date_time = wszFileTime;
GetTimeFormat (LOCALE_CUSTOM_UI_DEFAULT, TIME_NOSECONDS, &stModified, NULL, wszFileTime, 512);
date_time += L" ";
date_time += wszFileTime;
return date_time;
}