本文整理汇总了C++中CDateTime::SetFromDBTime方法的典型用法代码示例。如果您正苦于以下问题:C++ CDateTime::SetFromDBTime方法的具体用法?C++ CDateTime::SetFromDBTime怎么用?C++ CDateTime::SetFromDBTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDateTime
的用法示例。
在下文中一共展示了CDateTime::SetFromDBTime方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: GetNextEventTime
CDateTime CPVRTimers::GetNextEventTime(void) const
{
const bool dailywakup = CSettings::GetInstance().GetBool(CSettings::SETTING_PVRPOWERMANAGEMENT_DAILYWAKEUP);
const CDateTime now = CDateTime::GetUTCDateTime();
const CDateTimeSpan prewakeup(0, 0, CSettings::GetInstance().GetInt(CSettings::SETTING_PVRPOWERMANAGEMENT_PREWAKEUP), 0);
const CDateTimeSpan idle(0, 0, CSettings::GetInstance().GetInt(CSettings::SETTING_PVRPOWERMANAGEMENT_BACKENDIDLETIME), 0);
CDateTime wakeuptime;
/* Check next active time */
CFileItemPtr item = GetNextActiveTimer();
if (item && item->HasPVRTimerInfoTag())
{
const CDateTimeSpan prestart(0, 0, item->GetPVRTimerInfoTag()->MarginStart(), 0);
const CDateTime start = item->GetPVRTimerInfoTag()->StartAsUTC();
wakeuptime = ((start - prestart - prewakeup - idle) > now) ?
start - prestart - prewakeup :
now + idle;
}
/* check daily wake up */
if (dailywakup)
{
CDateTime dailywakeuptime;
dailywakeuptime.SetFromDBTime(CSettings::GetInstance().GetString(CSettings::SETTING_PVRPOWERMANAGEMENT_DAILYWAKEUPTIME));
dailywakeuptime = dailywakeuptime.GetAsUTCDateTime();
dailywakeuptime.SetDateTime(
now.GetYear(), now.GetMonth(), now.GetDay(),
dailywakeuptime.GetHour(), dailywakeuptime.GetMinute(), dailywakeuptime.GetSecond()
);
if ((dailywakeuptime - idle) < now)
{
const CDateTimeSpan oneDay(1,0,0,0);
dailywakeuptime += oneDay;
}
if (!wakeuptime.IsValid() || dailywakeuptime < wakeuptime)
wakeuptime = dailywakeuptime;
}
const CDateTime retVal(wakeuptime);
return retVal;
}
示例3: GetNextEventTime
CDateTime CPVRTimers::GetNextEventTime(void) const
{
const bool dailywakup = m_settings.GetBoolValue(CSettings::SETTING_PVRPOWERMANAGEMENT_DAILYWAKEUP);
const CDateTime now = CDateTime::GetUTCDateTime();
const CDateTimeSpan prewakeup(0, 0, m_settings.GetIntValue(CSettings::SETTING_PVRPOWERMANAGEMENT_PREWAKEUP), 0);
const CDateTimeSpan idle(0, 0, m_settings.GetIntValue(CSettings::SETTING_PVRPOWERMANAGEMENT_BACKENDIDLETIME), 0);
CDateTime wakeuptime;
/* Check next active time */
const std::shared_ptr<CPVRTimerInfoTag> timer = GetNextActiveTimer();
if (timer)
{
const CDateTimeSpan prestart(0, 0, timer->MarginStart(), 0);
const CDateTime start = timer->StartAsUTC();
wakeuptime = ((start - prestart - prewakeup - idle) > now) ?
start - prestart - prewakeup :
now + idle;
}
/* check daily wake up */
if (dailywakup)
{
CDateTime dailywakeuptime;
dailywakeuptime.SetFromDBTime(m_settings.GetStringValue(CSettings::SETTING_PVRPOWERMANAGEMENT_DAILYWAKEUPTIME));
dailywakeuptime = dailywakeuptime.GetAsUTCDateTime();
dailywakeuptime.SetDateTime(
now.GetYear(), now.GetMonth(), now.GetDay(),
dailywakeuptime.GetHour(), dailywakeuptime.GetMinute(), dailywakeuptime.GetSecond()
);
if ((dailywakeuptime - idle) < now)
{
const CDateTimeSpan oneDay(1,0,0,0);
dailywakeuptime += oneDay;
}
if (!wakeuptime.IsValid() || dailywakeuptime < wakeuptime)
wakeuptime = dailywakeuptime;
}
const CDateTime retVal(wakeuptime);
return retVal;
}
示例4: GetNextEventTime
CDateTime CPVRTimers::GetNextEventTime(void) const
{
const bool dailywakup = CSettings::Get().GetBool("pvrpowermanagement.dailywakeup");
const CDateTime now = CDateTime::GetUTCDateTime();
const CDateTimeSpan prewakeup(0, 0, CSettings::Get().GetInt("pvrpowermanagement.prewakeup"), 0);
const CDateTimeSpan idle(0, 0, CSettings::Get().GetInt("pvrpowermanagement.backendidletime"), 0);
CDateTime wakeuptime;
/* Check next active time */
CFileItemPtr item = GetNextActiveTimer();
if (item && item->HasPVRTimerInfoTag())
{
const CDateTimeSpan prestart(0, 0, item->GetPVRTimerInfoTag()->MarginStart(), 0);
const CDateTime start = item->GetPVRTimerInfoTag()->StartAsUTC();
wakeuptime = ((start - prestart - prewakeup - idle) > now) ?
start - prestart - prewakeup :
now + idle;
}
/* check daily wake up */
if (dailywakup)
{
CDateTime dailywakeuptime;
dailywakeuptime.SetFromDBTime(CSettings::Get().GetString("pvrpowermanagement.dailywakeuptime"));
dailywakeuptime = dailywakeuptime.GetAsUTCDateTime();
dailywakeuptime.SetDateTime(
now.GetYear(), now.GetMonth(), now.GetDay(),
dailywakeuptime.GetHour(), dailywakeuptime.GetMinute(), dailywakeuptime.GetSecond()
);
if ((dailywakeuptime - idle) < now)
{
const CDateTimeSpan oneDay(1,0,0,0);
dailywakeuptime += oneDay;
}
if (!wakeuptime.IsValid() || dailywakeuptime < wakeuptime)
wakeuptime = dailywakeuptime;
}
const CDateTime retVal(wakeuptime);
return retVal;
}
示例5: SetMode
void CGUIDialogNumeric::SetMode(INPUT_MODE mode, const CStdString &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(), NULL, 10);
dateTime = seconds;
}
else
{
CStdString 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.size() <= 5)
tmp = "00:" + tmp;
dateTime.SetFromDBTime(tmp);
}
}
else if (m_mode == INPUT_DATE)
{
CStdString 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
SetMode(mode, (void*)&initial);
}
示例6: OnClick
void CGUIEditControl::OnClick()
{
// we received a click - it's not from the keyboard, so pop up the virtual keyboard, unless
// that is where we reside!
if (GetParentID() == WINDOW_DIALOG_KEYBOARD)
return;
std::string utf8;
g_charsetConverter.wToUTF8(m_text2, utf8);
bool textChanged = false;
std::string heading = g_localizeStrings.Get(m_inputHeading ? m_inputHeading : 16028);
switch (m_inputType)
{
case INPUT_TYPE_READONLY:
textChanged = false;
break;
case INPUT_TYPE_NUMBER:
textChanged = CGUIDialogNumeric::ShowAndGetNumber(utf8, heading);
break;
case INPUT_TYPE_SECONDS:
textChanged = CGUIDialogNumeric::ShowAndGetSeconds(utf8, g_localizeStrings.Get(21420));
break;
case INPUT_TYPE_TIME:
{
CDateTime dateTime;
dateTime.SetFromDBTime(utf8);
SYSTEMTIME time;
dateTime.GetAsSystemTime(time);
if (CGUIDialogNumeric::ShowAndGetTime(time, !heading.empty() ? heading : g_localizeStrings.Get(21420)))
{
dateTime = CDateTime(time);
utf8 = dateTime.GetAsLocalizedTime("", false);
textChanged = true;
}
break;
}
case INPUT_TYPE_DATE:
{
CDateTime dateTime;
dateTime.SetFromDBDate(utf8);
if (dateTime < CDateTime(2000,1, 1, 0, 0, 0))
dateTime = CDateTime(2000, 1, 1, 0, 0, 0);
SYSTEMTIME date;
dateTime.GetAsSystemTime(date);
if (CGUIDialogNumeric::ShowAndGetDate(date, !heading.empty() ? heading : g_localizeStrings.Get(21420)))
{
dateTime = CDateTime(date);
utf8 = dateTime.GetAsDBDate();
textChanged = true;
}
break;
}
case INPUT_TYPE_IPADDRESS:
textChanged = CGUIDialogNumeric::ShowAndGetIPAddress(utf8, heading);
break;
case INPUT_TYPE_SEARCH:
textChanged = CGUIKeyboardFactory::ShowAndGetFilter(utf8, true);
break;
case INPUT_TYPE_FILTER:
textChanged = CGUIKeyboardFactory::ShowAndGetFilter(utf8, false);
break;
case INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW:
textChanged = CGUIDialogNumeric::ShowAndVerifyNewPassword(utf8);
break;
case INPUT_TYPE_PASSWORD_MD5:
utf8 = ""; // TODO: Ideally we'd send this to the keyboard and tell the keyboard we have this type of input
// fallthrough
case INPUT_TYPE_TEXT:
default:
textChanged = CGUIKeyboardFactory::ShowAndGetInput(utf8, heading, true, m_inputType == INPUT_TYPE_PASSWORD || m_inputType == INPUT_TYPE_PASSWORD_MD5);
break;
}
if (textChanged)
{
ClearMD5();
m_edit.clear();
g_charsetConverter.utf8ToW(utf8, m_text2);
m_cursorPos = m_text2.size();
UpdateText();
m_cursorPos = m_text2.size();
}
}
示例7: OnSearch
void CGUIDialogPVRGuideSearch::OnSearch()
{
CGUISpinControlEx *pSpin;
CGUIEditControl *pEdit;
CGUIRadioButtonControl *pRadioButton;
CDateTime dateTime;
if (!m_searchfilter)
return;
pEdit = (CGUIEditControl *)GetControl(CONTROL_EDIT_SEARCH);
if (pEdit) m_searchfilter->m_strSearchTerm = pEdit->GetLabel2();
pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_INC_DESC);
if (pRadioButton) m_searchfilter->m_bSearchInDescription = pRadioButton->IsSelected();
pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_CASE_SENS);
if (pRadioButton) m_searchfilter->m_bIsCaseSensitive = pRadioButton->IsSelected();
pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_FTA_ONLY);
if (pRadioButton) m_searchfilter->m_bFTAOnly = pRadioButton->IsSelected();
pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_UNK_GENRE);
if (pRadioButton) m_searchfilter->m_bIncludeUnknownGenres = pRadioButton->IsSelected();
pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_IGNORE_REC);
if (pRadioButton) m_searchfilter->m_bIgnorePresentRecordings = pRadioButton->IsSelected();
pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_IGNORE_TMR);
if (pRadioButton) m_searchfilter->m_bIgnorePresentTimers = pRadioButton->IsSelected();
pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_SPIN_NO_REPEATS);
if (pRadioButton) m_searchfilter->m_bPreventRepeats = pRadioButton->IsSelected();
pSpin = (CGUISpinControlEx *)GetControl(CONTROL_SPIN_GENRE);
if (pSpin) m_searchfilter->m_iGenreType = pSpin->GetValue();
pSpin = (CGUISpinControlEx *)GetControl(CONTROL_SPIN_MIN_DURATION);
if (pSpin) m_searchfilter->m_iMinimumDuration = pSpin->GetValue();
pSpin = (CGUISpinControlEx *)GetControl(CONTROL_SPIN_MAX_DURATION);
if (pSpin) m_searchfilter->m_iMaximumDuration = pSpin->GetValue();
pSpin = (CGUISpinControlEx *)GetControl(CONTROL_SPIN_CHANNELS);
if (pSpin) m_searchfilter->m_iChannelNumber = pSpin->GetValue();
pSpin = (CGUISpinControlEx *)GetControl(CONTROL_SPIN_GROUPS);
if (pSpin) m_searchfilter->m_iChannelGroup = pSpin->GetValue();
pEdit = (CGUIEditControl *)GetControl(CONTROL_EDIT_START_TIME);
if (pEdit)
{
dateTime.SetFromDBTime(pEdit->GetLabel2());
dateTime.GetAsSystemTime(m_searchfilter->m_startTime);
}
pEdit = (CGUIEditControl *)GetControl(CONTROL_EDIT_STOP_TIME);
if (pEdit)
{
dateTime.SetFromDBTime(pEdit->GetLabel2());
dateTime.GetAsSystemTime(m_searchfilter->m_endTime);
}
pEdit = (CGUIEditControl *)GetControl(CONTROL_EDIT_START_DATE);
if (pEdit)
{
dateTime.SetFromDBDate(pEdit->GetLabel2());
dateTime.GetAsSystemTime(m_searchfilter->m_startDate);
}
pEdit = (CGUIEditControl *)GetControl(CONTROL_EDIT_STOP_DATE);
if (pEdit)
{
dateTime.SetFromDBDate(pEdit->GetLabel2());
dateTime.GetAsSystemTime(m_searchfilter->m_endDate);
}
m_bConfirmed = true;
}
示例8: CanSystemPowerdown
bool CPVRManager::CanSystemPowerdown(bool bAskUser /*= true*/) const
{
bool bReturn(true);
if (IsStarted())
{
CPVRTimerInfoTagPtr cause;
if (!AllLocalBackendsIdle(cause))
{
if (bAskUser)
{
std::string text;
if (cause)
{
if (cause->IsRecording())
{
text = StringUtils::Format(g_localizeStrings.Get(19691).c_str(), // "PVR is currently recording...."
cause->Title().c_str(),
cause->ChannelName().c_str());
}
else
{
// Next event is due to a local recording.
const CDateTime now(CDateTime::GetUTCDateTime());
const CDateTime start(cause->StartAsUTC());
const CDateTimeSpan prestart(0, 0, cause->MarginStart(), 0);
CDateTimeSpan diff(start - now);
diff -= prestart;
int mins = diff.GetSecondsTotal() / 60;
std::string dueStr;
if (mins > 1)
{
// "%d minutes"
dueStr = StringUtils::Format(g_localizeStrings.Get(19694).c_str(), mins);
}
else
{
// "about a minute"
dueStr = g_localizeStrings.Get(19695);
}
text = StringUtils::Format(g_localizeStrings.Get(19692).c_str(), // "PVR will start recording...."
cause->Title().c_str(),
cause->ChannelName().c_str(),
dueStr.c_str());
}
}
else
{
// Next event is due to automatic daily wakeup of PVR.
const CDateTime now(CDateTime::GetUTCDateTime());
CDateTime dailywakeuptime;
dailywakeuptime.SetFromDBTime(CSettings::GetInstance().GetString(CSettings::SETTING_PVRPOWERMANAGEMENT_DAILYWAKEUPTIME));
dailywakeuptime = dailywakeuptime.GetAsUTCDateTime();
const CDateTimeSpan diff(dailywakeuptime - now);
int mins = diff.GetSecondsTotal() / 60;
std::string dueStr;
if (mins > 1)
{
// "%d minutes"
dueStr = StringUtils::Format(g_localizeStrings.Get(19694).c_str(), mins);
}
else
{
// "about a minute"
dueStr = g_localizeStrings.Get(19695);
}
text = StringUtils::Format(g_localizeStrings.Get(19693).c_str(), // "Daily wakeup is due in...."
dueStr.c_str());
}
// Inform user about PVR being busy. Ask if user wants to powerdown anyway.
bReturn = HELPERS::DialogResponse::YES ==
HELPERS::ShowYesNoDialogText(CVariant{19685}, // "Confirm shutdown"
CVariant{text},
CVariant{222}, // "Shutdown anyway",
CVariant{19696}, // "Cancel"
10000); // timeout value before closing
}
else
bReturn = false; // do not powerdown (busy, but no user interaction requested).
}
}
return bReturn;
}