本文整理汇总了C++中CDateTime::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ CDateTime::IsValid方法的具体用法?C++ CDateTime::IsValid怎么用?C++ CDateTime::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDateTime
的用法示例。
在下文中一共展示了CDateTime::IsValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetEPGDate
CDateTime CPVRChannelGroup::GetEPGDate(EpgDateType epgDateType) const
{
CDateTime date;
CSingleLock lock(m_critSection);
for (std::vector<PVRChannelGroupMember>::const_iterator it = m_members.begin(); it != m_members.end(); it++)
{
if (it->channel && !it->channel->IsHidden())
{
CEpg* epg = it->channel->GetEPG();
if (epg)
{
CDateTime epgDate;
switch (epgDateType)
{
case EPG_FIRST_DATE:
epgDate = epg->GetFirstDate();
if (epgDate.IsValid() && (!date.IsValid() || epgDate < date))
date = epgDate;
break;
case EPG_LAST_DATE:
epgDate = epg->GetLastDate();
if (epgDate.IsValid() && (!date.IsValid() || epgDate > date))
date = epgDate;
break;
}
}
}
}
return date;
}
示例2: GetEPGDate
CDateTime CPVRChannelGroup::GetEPGDate(EpgDateType epgDateType) const
{
CDateTime date;
CEpgPtr epg;
CPVRChannelPtr channel;
CSingleLock lock(m_critSection);
for (PVR_CHANNEL_GROUP_MEMBERS::const_iterator it = m_members.begin(); it != m_members.end(); ++it)
{
channel = it->second.channel;
if (!channel->IsHidden() && (epg = channel->GetEPG()))
{
CDateTime epgDate;
switch (epgDateType)
{
case EPG_FIRST_DATE:
epgDate = epg->GetFirstDate();
if (epgDate.IsValid() && (!date.IsValid() || epgDate < date))
date = epgDate;
break;
case EPG_LAST_DATE:
epgDate = epg->GetLastDate();
if (epgDate.IsValid() && (!date.IsValid() || epgDate > date))
date = epgDate;
break;
}
}
}
return date;
}
示例3: GetFirstEPGDate
const CDateTime CEpgContainer::GetFirstEPGDate(void) const
{
CDateTime returnValue;
CSingleLock lock(m_critSection);
for (unsigned int iEpgPtr = 0; iEpgPtr < size(); iEpgPtr++)
{
CDateTime entry = at(iEpgPtr)->GetFirstDate();
if (entry.IsValid() && (!returnValue.IsValid() || entry < returnValue))
returnValue = entry;
}
return returnValue;
}
示例4: GetCachedTexture
bool CTextureDatabase::GetCachedTexture(const CStdString &url, CTextureDetails &details)
{
try
{
if (NULL == m_pDB.get()) return false;
if (NULL == m_pDS.get()) return false;
CStdString sql = PrepareSQL("SELECT id, cachedurl, lasthashcheck, imagehash, width, height FROM texture JOIN sizes ON (texture.id=sizes.idtexture AND sizes.size=1) WHERE url='%s'", url.c_str());
m_pDS->query(sql.c_str());
if (!m_pDS->eof())
{ // have some information
details.id = m_pDS->fv(0).get_asInt();
details.file = m_pDS->fv(1).get_asString();
CDateTime lastCheck;
lastCheck.SetFromDBDateTime(m_pDS->fv(2).get_asString());
if (lastCheck.IsValid() && lastCheck + CDateTimeSpan(1,0,0,0) < CDateTime::GetCurrentDateTime())
details.hash = m_pDS->fv(3).get_asString();
details.width = m_pDS->fv(4).get_asInt();
details.height = m_pDS->fv(5).get_asInt();
m_pDS->close();
return true;
}
m_pDS->close();
}
catch (...)
{
CLog::Log(LOGERROR, "%s, failed on url '%s'", __FUNCTION__, url.c_str());
}
return false;
}
示例5: GetLastEPGDate
const CDateTime CEpgContainer::GetLastEPGDate(void)
{
CDateTime returnValue;
CSingleLock lock(m_critSection);
for (map<unsigned int, CEpg *>::iterator it = m_epgs.begin(); it != m_epgs.end(); it++)
{
lock.Leave();
CDateTime entry = it->second->GetLastDate();
if (entry.IsValid() && (!returnValue.IsValid() || entry > returnValue))
returnValue = entry;
lock.Enter();
}
return returnValue;
}
示例6: GetCachedTexture
bool CTextureDatabase::GetCachedTexture(const CStdString &url, CStdString &cacheFile, CStdString &imageHash)
{
try
{
if (NULL == m_pDB.get()) return false;
if (NULL == m_pDS.get()) return false;
CStdString sql = PrepareSQL("select id, cachedurl, lasthashcheck, imagehash from texture where url='%s'", url.c_str());
m_pDS->query(sql.c_str());
if (!m_pDS->eof())
{ // have some information
int textureID = m_pDS->fv(0).get_asInt();
cacheFile = m_pDS->fv(1).get_asString();
CDateTime lastCheck;
lastCheck.SetFromDBDateTime(m_pDS->fv(2).get_asString());
if (!lastCheck.IsValid() || lastCheck + CDateTimeSpan(1,0,0,0) < CDateTime::GetCurrentDateTime())
imageHash = m_pDS->fv(3).get_asString();
m_pDS->close();
// update the use count
sql = PrepareSQL("update texture set usecount=usecount+1, lastusetime=CURRENT_TIMESTAMP where id=%u", textureID);
m_pDS->exec(sql.c_str());
return true;
}
m_pDS->close();
}
catch (...)
{
CLog::Log(LOGERROR, "%s, failed on url '%s'", __FUNCTION__, url.c_str());
}
return false;
}
示例7: 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();
if (nextEvent.IsValid())
{
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;
}
示例8: GetLastEPGDate
const CDateTime CEpgContainer::GetLastEPGDate(void)
{
CDateTime returnValue;
CSingleLock lock(m_critSection);
for (const auto &epgEntry : m_epgs)
{
lock.Leave();
CDateTime entry = epgEntry.second->GetLastDate();
if (entry.IsValid() && (!returnValue.IsValid() || entry > returnValue))
returnValue = entry;
lock.Enter();
}
return returnValue;
}
示例9: GetFirstEPGDate
const CDateTime CEpgContainer::GetFirstEPGDate(void)
{
CDateTime returnValue;
CSingleLock lock(m_critSection);
for (EPGMAP_CITR it = m_epgs.begin(); it != m_epgs.end(); it++)
{
lock.Leave();
CDateTime entry = it->second->GetFirstDate();
if (entry.IsValid() && (!returnValue.IsValid() || entry < returnValue))
returnValue = entry;
lock.Enter();
}
return returnValue;
}
示例10: SetWakeupCommand
bool CPVRManager::SetWakeupCommand(void)
{
if (!CSettings::GetInstance().GetBool(CSettings::SETTING_PVRPOWERMANAGEMENT_ENABLED))
return false;
const std::string strWakeupCommand = CSettings::GetInstance().GetString(CSettings::SETTING_PVRPOWERMANAGEMENT_SETWAKEUPCMD);
if (!strWakeupCommand.empty() && m_timers)
{
time_t iWakeupTime;
const CDateTime nextEvent = m_timers->GetNextEventTime();
if (nextEvent.IsValid())
{
nextEvent.GetAsTime(iWakeupTime);
std::string strExecCommand = StringUtils::Format("%s %ld", strWakeupCommand.c_str(), 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;
}
示例11: SetMode
void CGUIDialogNumeric::SetMode(INPUT_MODE mode, const std::string &initial)
{
m_mode = mode;
m_block = 0;
m_lastblock = 0;
if (m_mode == INPUT_TIME || m_mode == INPUT_TIME_SECONDS || m_mode == INPUT_DATE)
{
CDateTime dateTime;
if (m_mode == INPUT_TIME || m_mode == INPUT_TIME_SECONDS)
{
// check if we have a pure number
if (initial.find_first_not_of("0123456789") == std::string::npos)
{
long seconds = strtol(initial.c_str(), nullptr, 10);
dateTime = seconds;
}
else
{
std::string tmp = initial;
// if we are handling seconds and if the string only contains
// "mm:ss" we need to add dummy "hh:" to get "hh:mm:ss"
if (m_mode == INPUT_TIME_SECONDS && tmp.length() <= 5)
tmp = "00:" + tmp;
dateTime.SetFromDBTime(tmp);
}
}
else if (m_mode == INPUT_DATE)
{
std::string tmp = initial;
StringUtils::Replace(tmp, '/', '.');
dateTime.SetFromDBDate(tmp);
}
if (!dateTime.IsValid())
return;
dateTime.GetAsSystemTime(m_datetime);
m_lastblock = (m_mode == INPUT_DATE) ? 2 : 1;
}
else if (m_mode == INPUT_IP_ADDRESS)
{
m_lastblock = 3;
auto blocks = StringUtils::Split(initial, '.');
if (blocks.size() != 4)
return;
for (size_t i = 0; i < blocks.size(); ++i)
{
if (blocks[i].length() > 3)
return;
m_ip[i] = static_cast<uint8_t>(atoi(blocks[i].c_str()));
}
}
else if (m_mode == INPUT_NUMBER || m_mode == INPUT_PASSWORD)
m_number = initial;
}
示例12: PersistTags
bool CEpg::PersistTags(void) const
{
bool bReturn = false;
CEpgDatabase *database = g_EpgContainer.GetDatabase();
if (!database || !database->IsOpen())
{
CLog::Log(LOGERROR, "EPG - %s - could not load the database", __FUNCTION__);
return bReturn;
}
CDateTime first = GetFirstDate();
CDateTime last = GetLastDate();
time_t iStart(0), iEnd(0);
if (first.IsValid())
first.GetAsTime(iStart);
if (last.IsValid())
last.GetAsTime(iEnd);
database->Delete(*this, iStart, iEnd);
if (m_tags.size() > 0)
{
for (map<CDateTime, CEpgInfoTag *>::const_iterator it = m_tags.begin(); it != m_tags.end(); it++)
{
if (!it->second->Persist())
{
CLog::Log(LOGERROR, "failed to persist epg tag %d", it->second->UniqueBroadcastID());
bReturn = false;
}
}
}
else
{
/* Return true if we have no tags, so that no error is logged */
bReturn = true;
}
return bReturn;
}
示例13: Format
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;
}
示例14: Modified
bool CXmlFile::Modified()
{
wxCHECK(!m_fileName.empty(), false);
if (!m_modificationTime.IsValid())
return true;
CDateTime const modificationTime = CLocalFileSystem::GetModificationTime(m_fileName);
if (modificationTime.IsValid() && modificationTime == m_modificationTime)
return false;
return true;
}
示例15: LastRepoUpdate
CDateTime CAddonInstaller::LastRepoUpdate() const
{
CDateTime update;
VECADDONS addons;
CAddonMgr::Get().GetAddons(ADDON_REPOSITORY,addons);
for (unsigned int i=0;i<addons.size();++i)
{
CAddonDatabase database;
database.Open();
CDateTime lastUpdate = database.GetRepoTimestamp(addons[i]->ID());
if (lastUpdate.IsValid() && lastUpdate > update)
update = lastUpdate;
}
return update;
}