Пример #1
0
wxString CTimeFormat::Format(CDateTime const& time)
{
	wxString ret;
	if( time.IsValid() ) {
		if( time.GetAccuracy() > CDateTime::days ) {
			ret = FormatDateTime(time.Degenerate());
		}
		else {
			ret = FormatDate(time.Degenerate());
		}
	}
	return ret;
}
Пример #2
0
bool CLocalFileSystem::ConvertCDateTimeToFileTime(FILETIME &ft, const CDateTime& time)
{
	if (!time.IsValid())
		return false;

	wxLongLong t = time.Degenerate().GetValue();

	t += EPOCH_OFFSET_IN_MSEC;
	t *= 10000;

	ft.dwHighDateTime = t.GetHi();
	ft.dwLowDateTime = t.GetLo();

	return true;
}
Пример #3
0
bool CLocalFileSystem::SetModificationTime(const wxString& path, const CDateTime& t)
{
	if (!t.IsValid())
		return false;

#ifdef __WXMSW__
	FILETIME ft;
	if (!ConvertCDateTimeToFileTime(ft, t))
		return false;

	HANDLE h = CreateFile(path, GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
	if (h == INVALID_HANDLE_VALUE)
		return false;

	bool ret = SetFileTime(h, 0, &ft, &ft) == TRUE;
	CloseHandle(h);
	return ret;
#else
	wxFileName fn(path);
	wxDateTime d = t.Degenerate();
	return fn.SetTimes( &d, &d, 0 );
#endif
}