当前位置: 首页>>代码示例>>C++>>正文


C++ CDateTime类代码示例

本文整理汇总了C++中CDateTime的典型用法代码示例。如果您正苦于以下问题:C++ CDateTime类的具体用法?C++ CDateTime怎么用?C++ CDateTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CDateTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: lock

int CEpg::Get(CFileItemList &results, const EpgSearchFilter &filter) const
{
  int iInitialSize = results.Size();

  if (!HasValidEntries())
    return -1;

  CSingleLock lock(m_critSection);

  for (map<CDateTime, CEpgInfoTag *>::const_iterator it = m_tags.begin(); it != m_tags.end(); it++)
  {
    if (filter.FilterEntry(*it->second))
    {
      CDateTime localStartTime;
      localStartTime.SetFromUTCDateTime(it->first);

      CFileItemPtr entry(new CFileItem(*it->second));
      entry->SetLabel2(localStartTime.GetAsLocalizedDateTime(false, false));
      results.Add(entry);
    }
  }

  return results.Size() - iInitialSize;
}
开发者ID:Omel,项目名称:xbmc,代码行数:24,代码来源:Epg.cpp

示例2: newStart

void CGUIDialogPVRTimerSettings::OnSettingAction(const CSetting *setting)
{
  if (setting == NULL)
    return;

  CGUIDialogSettingsManualBase::OnSettingAction(setting);

  CPVRTimerInfoTag* tag = m_timerItem->GetPVRTimerInfoTag();
  if (tag == NULL)
    return;

  const std::string &settingId = setting->GetId();
  if (settingId == SETTING_TMR_BEGIN)
  {
    if (CGUIDialogNumeric::ShowAndGetTime(m_timerStartTime, g_localizeStrings.Get(14066)))
    {
      CDateTime timestart = m_timerStartTime;
      int start_day       = tag->StartAsLocalTime().GetDay();
      int start_month     = tag->StartAsLocalTime().GetMonth();
      int start_year      = tag->StartAsLocalTime().GetYear();
      int start_hour      = timestart.GetHour();
      int start_minute    = timestart.GetMinute();
      CDateTime newStart(start_year, start_month, start_day, start_hour, start_minute, 0);
      tag->SetStartFromLocalTime(newStart);

      m_timerStartTimeStr = tag->StartAsLocalTime().GetAsLocalizedTime("", false);
      setButtonLabels();
    }
  }
  else if (settingId == SETTING_TMR_END)
  {
    if (CGUIDialogNumeric::ShowAndGetTime(m_timerEndTime, g_localizeStrings.Get(14066)))
    {
      CDateTime timestop = m_timerEndTime;
      // TODO: add separate end date control to schedule a show with more then 24 hours
      int start_day       = tag->StartAsLocalTime().GetDay();
      int start_month     = tag->StartAsLocalTime().GetMonth();
      int start_year      = tag->StartAsLocalTime().GetYear();
      int start_hour      = timestop.GetHour();
      int start_minute    = timestop.GetMinute();
      CDateTime newEnd(start_year, start_month, start_day, start_hour, start_minute, 0);
      
      // add a day to end time if end time is before start time
      // TODO: this should be removed after separate end date control was added
      if (newEnd < tag->StartAsLocalTime())
        newEnd += CDateTimeSpan(1, 0, 0, 0);

      tag->SetEndFromLocalTime(newEnd);

      m_timerEndTimeStr = tag->EndAsLocalTime().GetAsLocalizedTime("", false);
      setButtonLabels();
    }
  }

  tag->UpdateSummary();
}
开发者ID:Inz999,项目名称:xbmc,代码行数:56,代码来源:GUIDialogPVRTimerSettings.cpp

示例3: IsRequestRanged

bool CWebServer::IsRequestRanged(const HTTPRequest& request, const CDateTime &lastModified) const
{
  // parse the Range header and store it in the request object
  CHttpRanges ranges;
  bool ranged = ranges.Parse(HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_RANGE));

  // handle If-Range header but only if the Range header is present
  if (ranged && lastModified.IsValid())
  {
    std::string ifRange = HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_RANGE);
    if (!ifRange.empty() && lastModified.IsValid())
    {
      CDateTime ifRangeDate;
      ifRangeDate.SetFromRFC1123DateTime(ifRange);

      // check if the last modification is newer than the If-Range date
      // if so we have to server the whole file instead
      if (lastModified.GetAsUTCDateTime() > ifRangeDate)
        ranges.Clear();
    }
  }

  return !ranges.IsEmpty();
}
开发者ID:Arcko,项目名称:xbmc,代码行数:24,代码来源:WebServer.cpp

示例4: SetWakeupCommand

bool CPVRManager::SetWakeupCommand(void)
{
  if (!g_guiSettings.GetBool("pvrpowermanagement.enabled"))
    return false;

  const CStdString strWakeupCommand = g_guiSettings.GetString("pvrpowermanagement.setwakeupcmd", false);
  if (!strWakeupCommand.IsEmpty() && m_timers)
  {
    time_t iWakeupTime;
    const CDateTime nextEvent = m_timers->GetNextEventTime();
    nextEvent.GetAsTime(iWakeupTime);

    CStdString strExecCommand;
    strExecCommand.Format("%s %d", strWakeupCommand, iWakeupTime);

    const int iReturn = system(strExecCommand.c_str());
    if (iReturn != 0)
      CLog::Log(LOGERROR, "%s - failed to execute wakeup command '%s': %s (%d)", __FUNCTION__, strExecCommand.c_str(), strerror(iReturn), iReturn);

    return iReturn == 0;
  }

  return false;
}
开发者ID:OV3RDOSE,项目名称:xbmc,代码行数:24,代码来源:PVRManager.cpp

示例5: show

 // Write instance of the CDateTime class into the given writer.
 static void show(IWriter& writer, const CDateTime& a_crDateTime)
 { CALL
   writer << fill_0 << width(2) << a_crDateTime.getDate().getDay() << STR('.');
   writer << fill_0 << width(2) << a_crDateTime.getDate().getMonth() << STR('.');
   writer << fill_0 << width(4) << a_crDateTime.getDate().getYear() << STR(' ');
   writer << fill_0 << width(2) << a_crDateTime.getTime().getHour() << STR(':');
   writer << fill_0 << width(2) << a_crDateTime.getTime().getMinute() << STR(':');
   writer << fill_0 << width(2) << a_crDateTime.getTime().getSecond() << STR('-');
   writer << fill_0 << width(4) << a_crDateTime.getTime().getMillisecond() << ln;
 }
开发者ID:pombredanne,项目名称:Depth,代码行数:11,代码来源:example-time-CDateTime.cpp

示例6: Exist

/*
	Exist()
*/
BOOL CUrlDatabaseService::Exist(LPCSTR lpcszUrl,LPSTR lpszDate,UINT nDateSize,CUrlStatus::URL_STATUS& nStat,UINT& nID)
{
	BOOL bExist = FALSE;
	nStat = CUrlStatus::URL_STATUS_UNKNOWN;
	nID = 0;

	if(m_bIsValid)
	{
		// sincronizza gli accessi
		if(m_pUrlDatabaseTable->Lock(SYNC_5_SECS_TIMEOUT))
		{
			strcpyn(m_szUrl,lpcszUrl,sizeof(m_szUrl));
			m_Url.DecodeUrl(m_szUrl);

			// controlla se il valore specificato esiste
			if(m_pUrlDatabaseTable->Seek(m_szUrl,URLDATABASE_IDX_URL))
			{
				m_pUrlDatabaseTable->ScatterMemvars();

				CDateTime* pDate = m_pUrlDatabaseTable->GetField_Date();
				CDateTime* pTime = m_pUrlDatabaseTable->GetField_StartTime();
				m_DateTime.SetYear(pDate->GetYear());
				m_DateTime.SetMonth(pDate->GetMonth());
				m_DateTime.SetDay(pDate->GetDay());
				m_DateTime.SetHour(pTime->GetHour());
				m_DateTime.SetMin(pTime->GetMin());
				m_DateTime.SetSec(pTime->GetSec());
				m_DateTime.SetDateFormat(GMT);
				strcpyn(lpszDate,m_DateTime.GetFormattedDate(FALSE),nDateSize);
				nStat = (CUrlStatus::URL_STATUS)m_pUrlDatabaseTable->GetField_Status();
				nID = m_pUrlDatabaseTable->GetField_Id();
				
				bExist = TRUE;
			}
			else
			{
				memset(lpszDate,'\0',nDateSize);
			}

			m_pUrlDatabaseTable->Unlock();
		}
	}

	return(bExist);
}
开发者ID:code4bones,项目名称:crawlpaper,代码行数:48,代码来源:CUrlDatabaseService.cpp

示例7: SetLastUpdated

bool CAddonDatabase::SetLastUpdated(const std::string& addonId, const CDateTime& dateTime)
{
  try
  {
    if (NULL == m_pDB.get()) return false;
    if (NULL == m_pDS.get()) return false;

    m_pDS->exec(PrepareSQL("UPDATE installed SET lastUpdated='%s' WHERE addonID='%s'",
        dateTime.GetAsDBDateTime().c_str(), addonId.c_str()));
    return true;
  }
  catch (...)
  {
    CLog::Log(LOGERROR, "%s failed on addon '%s'", __FUNCTION__, addonId.c_str());
  }
  return false;
}
开发者ID:Montellese,项目名称:xbmc,代码行数:17,代码来源:AddonDatabase.cpp

示例8: strDirectoryN

CPVRRecordingsPath::CPVRRecordingsPath(bool bDeleted, bool bRadio,
                       const std::string &strDirectory, const std::string &strTitle,
                       int iSeason, int iEpisode, int iYear,
                       const std::string &strSubtitle, const std::string &strChannelName,
                       const CDateTime &recordingTime, const std::string &strId)
: m_bValid(true),
  m_bRoot(false),
  m_bActive(!bDeleted),
  m_bRadio(bRadio)
{
  std::string strDirectoryN(TrimSlashes(strDirectory));
  if (!strDirectoryN.empty())
    strDirectoryN = StringUtils::Format("%s/", strDirectoryN.c_str());

  std::string strTitleN(strTitle);
  StringUtils::Replace(strTitleN, '/', ' ');

  std::string strSeasonEpisodeN;
  if ((iSeason > -1 && iEpisode > -1 && (iSeason > 0 || iEpisode > 0)))
    strSeasonEpisodeN = StringUtils::Format("s%02de%02d", iSeason, iEpisode);
  if (!strSeasonEpisodeN.empty())
    strSeasonEpisodeN = StringUtils::Format(" %s", strSeasonEpisodeN.c_str());

  std::string strYearN(iYear > 0 ? StringUtils::Format(" (%i)", iYear) : "");

  std::string strSubtitleN;
  if (!strSubtitle.empty())
  {
    strSubtitleN = StringUtils::Format(" %s", strSubtitle.c_str());
    StringUtils::Replace(strSubtitleN, '/', ' ');
  }

  std::string strChannelNameN;
  if (!strChannelName.empty())
  {
    strChannelNameN = StringUtils::Format(" (%s)", strChannelName.c_str());
    StringUtils::Replace(strChannelNameN, '/', ' ');
  }

  m_directoryPath = StringUtils::Format("%s%s%s%s%s",
                                        strDirectoryN.c_str(), strTitleN.c_str(), strSeasonEpisodeN.c_str(),
                                        strYearN.c_str(), strSubtitleN.c_str());
  m_params = StringUtils::Format(", TV%s, %s, %s.pvr", strChannelNameN.c_str(), recordingTime.GetAsSaveString().c_str(), strId.c_str());
  m_path   = StringUtils::Format("pvr://recordings/%s/%s/%s%s", bRadio ? "radio" : "tv", bDeleted ? "deleted" : "active", m_directoryPath.c_str(), m_params.c_str());
}
开发者ID:Jalle19,项目名称:xbmc,代码行数:45,代码来源:PVRRecordingsPath.cpp

示例9: ToULargeInt

CDateTimeSpan CDateTime::operator -(const CDateTime& right) const
{
    CDateTimeSpan left;

    ULARGE_INTEGER timeLeft;
    left.ToULargeInt(timeLeft);

    ULARGE_INTEGER timeThis;
    ToULargeInt(timeThis);

    ULARGE_INTEGER timeRight;
    right.ToULargeInt(timeRight);

    timeLeft.QuadPart=timeThis.QuadPart-timeRight.QuadPart;

    left.FromULargeInt(timeLeft);

    return left;
}
开发者ID:sandalsoft,项目名称:mrmc,代码行数:19,代码来源:XBDateTime.cpp

示例10: SetLastUsed

bool CAddonDatabase::SetLastUsed(const std::string& addonId, const CDateTime& dateTime)
{
  try
  {
    if (NULL == m_pDB.get()) return false;
    if (NULL == m_pDS.get()) return false;

    auto start = XbmcThreads::SystemClockMillis();
    m_pDS->exec(PrepareSQL("UPDATE installed SET lastUsed='%s' WHERE addonID='%s'",
        dateTime.GetAsDBDateTime().c_str(), addonId.c_str()));

    CLog::Log(LOGDEBUG, "CAddonDatabase::SetLastUsed[%s] took %i ms", addonId.c_str(), XbmcThreads::SystemClockMillis() - start);
    return true;
  }
  catch (...)
  {
    CLog::Log(LOGERROR, "%s failed on addon '%s'", __FUNCTION__, addonId.c_str());
  }
  return false;
}
开发者ID:Montellese,项目名称:xbmc,代码行数:20,代码来源:AddonDatabase.cpp

示例11: t

bool CLocalFileSystem::ConvertFileTimeToCDateTime(CDateTime& time, const FILETIME &ft)
{
	if (!ft.dwHighDateTime && !ft.dwLowDateTime)
		return false;

	// See http://trac.wxwidgets.org/changeset/74423 and http://trac.wxwidgets.org/ticket/13098
	// Directly converting to time_t

	wxLongLong t(ft.dwHighDateTime, ft.dwLowDateTime);
	t /= 10000; // Convert hundreds of nanoseconds to milliseconds.
	t -= EPOCH_OFFSET_IN_MSEC;
	if (t < 0) {
		return false;
	}

	// Interestingly wxDateTime has this constructor which
	// even more interestingly isn't even marked explicit.
	time = CDateTime(wxDateTime(t), CDateTime::milliseconds);
	return time.IsValid();
}
开发者ID:Typz,项目名称:FileZilla,代码行数:20,代码来源:local_filesys.cpp

示例12: DisplayFile

void CFileExistsDlg::DisplayFile(bool left, wxString name, wxLongLong const& size, CDateTime const& time, wxString const& iconFile)
{
	name = GetPathEllipsis(name, FindWindow(left ? XRCID("ID_FILE1_NAME") : XRCID("ID_FILE2_NAME")));
	name.Replace(_T("&"), _T("&&"));

	wxString sizeStr = _("Size unknown");
	if (size != -1) {
		bool const thousands_separator = COptions::Get()->GetOptionVal(OPTION_SIZE_USETHOUSANDSEP) != 0;
		sizeStr = CSizeFormat::Format(size, true, CSizeFormat::bytes, thousands_separator, 0);
	}

	wxString timeStr = _("Date/time unknown");
	if (time.IsValid())
		timeStr = CTimeFormat::Format(time);

	xrc_call(*this, left ? "ID_FILE1_NAME" : "ID_FILE2_NAME", &wxStaticText::SetLabel, name);
	xrc_call(*this, left ? "ID_FILE1_SIZE" : "ID_FILE2_SIZE", &wxStaticText::SetLabel, sizeStr);
	xrc_call(*this, left ? "ID_FILE1_TIME" : "ID_FILE2_TIME", &wxStaticText::SetLabel, timeStr);

	LoadIcon(left ? XRCID("ID_FILE1_ICON") : XRCID("ID_FILE2_ICON"), iconFile);
}
开发者ID:Typz,项目名称:FileZilla,代码行数:21,代码来源:fileexistsdlg.cpp

示例13: GetLastModifiedOfTestFile

  bool GetLastModifiedOfTestFile(const std::string& testFile, CDateTime& lastModified)
  {
    CFile file;
    if (!file.Open(URIUtils::AddFileToFolder(sourcePath, testFile), READ_NO_CACHE))
      return false;

    struct __stat64 statBuffer;
    if (file.Stat(&statBuffer) != 0)
      return false;

    struct tm *time;
#ifdef HAVE_LOCALTIME_R
    struct tm result = {};
    time = localtime_r((time_t*)&statBuffer.st_mtime, &result);
#else
    time = localtime((time_t *)&statBuffer.st_mtime);
#endif
    if (time == NULL)
      return false;

    lastModified = *time;
    return lastModified.IsValid();
  }
开发者ID:bfg1981,项目名称:xbmc,代码行数:23,代码来源:TestWebServer.cpp

示例14: now

void CGUIDialogPVRTimerSettings::DaysFiller(
  const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int &current, void *data)
{
  CGUIDialogPVRTimerSettings *pThis = static_cast<CGUIDialogPVRTimerSettings*>(data);
  if (pThis)
  {
    list.clear();
    current = 0;

    // Data range: "today" until "yesterday next year"
    const CDateTime now(CDateTime::GetCurrentDateTime());
    CDateTime time(now.GetYear(), now.GetMonth(), now.GetDay(), 0, 0, 0);
    const CDateTime yesterdayPlusOneYear(
      time.GetYear() + 1, time.GetMonth(), time.GetDay() - 1, time.GetHour(), time.GetMinute(), time.GetSecond());

    CDateTime oldCDateTime;
    if (setting->GetId() == SETTING_TMR_FIRST_DAY)
      oldCDateTime = pThis->m_timerInfoTag->FirstDayAsLocalTime();
    else if (setting->GetId() == SETTING_TMR_START_DAY)
      oldCDateTime = pThis->m_timerInfoTag->StartAsLocalTime();
    else
      oldCDateTime = pThis->m_timerInfoTag->EndAsLocalTime();
    const CDateTime oldCDate(oldCDateTime.GetYear(), oldCDateTime.GetMonth(), oldCDateTime.GetDay(), 0, 0, 0);

    if ((oldCDate < time) || (oldCDate > yesterdayPlusOneYear))
      list.push_back(std::make_pair(oldCDate.GetAsLocalizedDate(true /*long date*/), GetDateAsIndex(oldCDate)));

    while (time <= yesterdayPlusOneYear)
    {
      list.push_back(std::make_pair(time.GetAsLocalizedDate(true /*long date*/), GetDateAsIndex(time)));
      time += CDateTimeSpan(1, 0, 0, 0);
    }

    if (setting->GetId() == SETTING_TMR_FIRST_DAY)
      current = GetDateAsIndex(pThis->m_firstDayLocalTime);
    else if (setting->GetId() == SETTING_TMR_START_DAY)
      current = GetDateAsIndex(pThis->m_startLocalTime);
    else
      current = GetDateAsIndex(pThis->m_endLocalTime);
  }
  else
    CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::DaysFiller - No dialog");
}
开发者ID:JackSLLIN,项目名称:xbmc,代码行数:43,代码来源:GUIDialogPVRTimerSettings.cpp

示例15: GetFileTime

/*
	GetFileTime()

	Ricava la data/ora UTC del file (assolute, in formato GMT). Se il secondo parametro e' TRUE,
	converte da GMT a local time, aggiungendo o sottraendo la differenza oraria rispetto a GMT:

	- data/ora assolute del file (UTC=GMT): Sun, 06 Nov 1994 08:49:37 GMT (0000)
	- zona oraria locale: GMT +1 (+0100)

	bConvertToLocalTime = FALSE -> Sun, 06 Nov 1994 08:49:37 GMT
	bConvertToLocalTime = TRUE  -> Sun, 06 Nov 1994 09:49:37 +0100
*/
BOOL CBinFile::GetFileTime(CDateTime& datetime,BOOL bConvertToLocalTime/* = FALSE*/)
{
	BOOL bGet = FALSE;

	if(m_hHandle!=INVALID_HANDLE_VALUE)
	{
		FILETIME   gmtfiletime = {0};
		FILETIME   filetime = {0};
		SYSTEMTIME systemtime = {0};

		// ricava la data/ora UTC del file (ossia assolute, GMT)
		if(::GetFileTime(m_hHandle,NULL,NULL,&gmtfiletime))
		{
			if(bConvertToLocalTime)
				::FileTimeToLocalFileTime(&gmtfiletime,&filetime); // converte in locale (aggiunge o sottrae la differenza rispetto a GMT)
			else
				memcpy(&filetime,&gmtfiletime,sizeof(FILETIME)); // nessuna conversione, data/ora assolute (UTC)

			// converte in formato di sistema
			::FileTimeToSystemTime(&filetime,&systemtime);
			
			// formatta la data/ora del file (Day, dd Mon yyyy hh:mm:ss [GMT])
			datetime.SetDateFormat(bConvertToLocalTime ? GMT : GMT_SHORT);
			datetime.SetYear(systemtime.wYear);
			datetime.SetMonth(systemtime.wMonth);
			datetime.SetDay(systemtime.wDay);
			datetime.SetHour(systemtime.wHour);
			datetime.SetMin(systemtime.wMinute);
			datetime.SetSec(systemtime.wSecond);
			
			bGet = TRUE;
		}
	}

	return(bGet);
}
开发者ID:code4bones,项目名称:crawlpaper,代码行数:48,代码来源:CBinFile.cpp


注:本文中的CDateTime类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。