本文整理汇总了C++中CDateTime::GetAsTm方法的典型用法代码示例。如果您正苦于以下问题:C++ CDateTime::GetAsTm方法的具体用法?C++ CDateTime::GetAsTm怎么用?C++ CDateTime::GetAsTm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDateTime
的用法示例。
在下文中一共展示了CDateTime::GetAsTm方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnSettingChanged
void CGUIDialogPVRTimerSettings::OnSettingChanged(const CSetting *setting)
{
if (setting == NULL)
return;
CGUIDialogSettingsManualBase::OnSettingChanged(setting);
CPVRTimerInfoTag* tag = m_timerItem->GetPVRTimerInfoTag();
if (tag == NULL)
return;
const std::string &settingId = setting->GetId();
if (settingId == SETTING_TMR_ACTIVE)
m_bTimerActive = static_cast<const CSettingBool*>(setting)->GetValue();
if (settingId == SETTING_TMR_RADIO || settingId == SETTING_TMR_CHNAME_TV || settingId == SETTING_TMR_CHNAME_RADIO)
{
if (settingId == SETTING_TMR_RADIO)
{
tag->m_bIsRadio = static_cast<const CSettingBool*>(setting)->GetValue();
m_selectedChannelEntry = 0;
}
else
m_selectedChannelEntry = static_cast<const CSettingInt*>(setting)->GetValue();
std::map<std::pair<bool, int>, int>::iterator itc = m_channelEntries.find(std::make_pair(tag->m_bIsRadio, m_selectedChannelEntry));
if (itc != m_channelEntries.end())
{
CPVRChannelPtr channel = g_PVRChannelGroups->GetChannelById(itc->second);
if (channel)
{
tag->m_iClientChannelUid = channel->UniqueID();
tag->m_iClientId = channel->ClientID();
tag->m_bIsRadio = channel->IsRadio();
tag->m_iChannelNumber = channel->ChannelNumber();
}
else
{
tag->m_iClientChannelUid = PVR_VIRTUAL_CHANNEL_UID;
tag->m_iClientId = PVR_VIRTUAL_CLIENT_ID;
tag->m_iChannelNumber = 0;
}
// Update channel pointer from above values
tag->UpdateChannel();
}
}
else if (settingId == SETTING_TMR_DAY)
{
m_tmp_day = static_cast<const CSettingInt*>(setting)->GetValue();
if (m_tmp_day <= 10)
SetTimerFromWeekdaySetting(*tag);
else
{
CDateTime time = CDateTime::GetCurrentDateTime();
CDateTime timestart = m_timerStartTime;
CDateTime timestop = m_timerEndTime;
int m_tmp_diff;
// get diffence of timer in days between today and timer start date
tm time_cur; time.GetAsTm(time_cur);
tm time_tmr; timestart.GetAsTm(time_tmr);
m_tmp_diff = time_tmr.tm_yday - time_cur.tm_yday;
if (time_tmr.tm_yday - time_cur.tm_yday < 0)
m_tmp_diff = 365;
CDateTime newStart = timestart + CDateTimeSpan(m_tmp_day - 11 - m_tmp_diff, 0, 0, 0);
CDateTime newEnd = timestop + CDateTimeSpan(m_tmp_day - 11 - m_tmp_diff, 0, 0, 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 < newStart)
newEnd += CDateTimeSpan(1, 0, 0, 0);
tag->SetStartFromLocalTime(newStart);
tag->SetEndFromLocalTime(newEnd);
tag->m_bIsRepeating = false;
tag->m_iWeekdays = 0;
}
}
else if (settingId == SETTING_TMR_PRIORITY)
tag->m_iPriority = static_cast<const CSettingInt*>(setting)->GetValue();
else if (settingId == SETTING_TMR_LIFETIME)
tag->m_iLifetime = static_cast<const CSettingInt*>(setting)->GetValue();
else if (settingId == SETTING_TMR_FIRST_DAY)
{
m_tmp_iFirstDay = static_cast<const CSettingInt*>(setting)->GetValue();
CDateTime newFirstDay;
if (m_tmp_iFirstDay > 0)
newFirstDay = CDateTime::GetCurrentDateTime() + CDateTimeSpan(m_tmp_iFirstDay - 1, 0, 0, 0);
tag->SetFirstDayFromLocalTime(newFirstDay);
}
else if (settingId == SETTING_TMR_NAME)
tag->m_strTitle = static_cast<const CSettingString*>(setting)->GetValue();
else if (settingId == SETTING_TMR_DIR)
tag->m_strDirectory = static_cast<const CSettingString*>(setting)->GetValue();
//.........这里部分代码省略.........
示例2: InitializeSettings
void CGUIDialogPVRTimerSettings::InitializeSettings()
{
CGUIDialogSettingsManualBase::InitializeSettings();
CSettingCategory *category = AddCategory("pvrtimersettings", -1);
if (category == NULL)
{
CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings: unable to setup settings");
return;
}
CSettingGroup *group = AddGroup(category);
if (group == NULL)
{
CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings: unable to setup settings");
return;
}
// add a condition
m_settingsManager->AddCondition("IsTimerDayRepeating", IsTimerDayRepeating);
CPVRTimerInfoTag* tag = m_timerItem->GetPVRTimerInfoTag();
m_selectedChannelEntry = 0;
m_channelEntries.clear();
m_bTimerActive = tag->IsActive();
AddToggle(group, SETTING_TMR_ACTIVE, 19074, 0, m_bTimerActive);
AddEdit(group, SETTING_TMR_NAME, 19075, 0, tag->m_strTitle, false, false, 19097);
if (tag->SupportsFolders())
AddEdit(group, SETTING_TMR_DIR, 19076, 0, tag->m_strDirectory, true, false, 19104);
AddToggle(group, SETTING_TMR_RADIO, 19077, 0, tag->m_bIsRadio);
/// Channel names
{
// For TV
AddChannelNames(group, false);
// For Radio
AddChannelNames(group, true);
}
/// Day
{
// get diffence of timer in days between today and timer start date
tm time_cur; CDateTime::GetCurrentDateTime().GetAsTm(time_cur);
tm time_tmr; tag->StartAsLocalTime().GetAsTm(time_tmr);
m_tmp_day += time_tmr.tm_yday - time_cur.tm_yday;
if (time_tmr.tm_yday - time_cur.tm_yday < 0)
m_tmp_day += 365;
SetWeekdaySettingFromTimer(*tag);
AddSpinner(group, SETTING_TMR_DAY, 19079, 0, m_tmp_day, DaysOptionsFiller);
}
AddButton(group, SETTING_TMR_BEGIN, 19080, 0);
AddButton(group, SETTING_TMR_END, 19081, 0);
AddSpinner(group, SETTING_TMR_PRIORITY, 19082, 0, tag->m_iPriority, 0, 1, 99);
AddSpinner(group, SETTING_TMR_LIFETIME, 19083, 0, tag->m_iLifetime, 0, 1, 365);
/// First day
{
CDateTime time = CDateTime::GetCurrentDateTime();
CDateTime timestart = tag->FirstDayAsLocalTime();
// get diffence of timer in days between today and timer start date
if (time < timestart)
{
tm time_cur; time.GetAsTm(time_cur);
tm time_tmr; timestart.GetAsTm(time_tmr);
m_tmp_iFirstDay += time_tmr.tm_yday - time_cur.tm_yday + 1;
if (time_tmr.tm_yday - time_cur.tm_yday < 0)
m_tmp_iFirstDay += 365;
}
CSettingInt *settingFirstDay = AddSpinner(group, SETTING_TMR_FIRST_DAY, 19084, 0, m_tmp_iFirstDay, DaysOptionsFiller);
// define an enable dependency with m_tmp_day <= 10
CSettingDependency depdendencyFirstDay(SettingDependencyTypeEnable, m_settingsManager);
depdendencyFirstDay.And()
->Add(CSettingDependencyConditionPtr(new CSettingDependencyCondition("IsTimerDayRepeating", "true", SETTING_TMR_DAY, false, m_settingsManager)));
SettingDependencies deps;
deps.push_back(depdendencyFirstDay);
settingFirstDay->SetDependencies(deps);
}
}
示例3: OnSettingChanged
void CGUIDialogPVRTimerSettings::OnSettingChanged(SettingInfo &setting)
{
CPVRTimerInfoTag* tag = m_timerItem->GetPVRTimerInfoTag();
if (setting.id == CONTROL_TMR_NAME)
{
if (CGUIKeyboardFactory::ShowAndGetInput(tag->m_strTitle, g_localizeStrings.Get(19097), false))
{
UpdateSetting(CONTROL_TMR_NAME);
}
}
if (setting.id == CONTROL_TMR_DIR && CGUIKeyboardFactory::ShowAndGetInput(tag->m_strDirectory, g_localizeStrings.Get(19104), false))
UpdateSetting(CONTROL_TMR_DIR);
else if (setting.id == CONTROL_TMR_RADIO || setting.id == CONTROL_TMR_CHNAME_TV || setting.id == CONTROL_TMR_CHNAME_RADIO)
{
if (setting.id == CONTROL_TMR_RADIO)
{
EnableSettings(CONTROL_TMR_CHNAME_TV, !tag->m_bIsRadio);
EnableSettings(CONTROL_TMR_CHNAME_RADIO, tag->m_bIsRadio);
}
CFileItemPtr channel = g_PVRChannelGroups->GetGroupAll(tag->m_bIsRadio)->GetByChannelNumber(tag->m_iChannelNumber);
if (channel && channel->HasPVRChannelInfoTag())
{
tag->m_iClientChannelUid = channel->GetPVRChannelInfoTag()->UniqueID();
tag->m_iClientId = channel->GetPVRChannelInfoTag()->ClientID();
tag->m_bIsRadio = channel->GetPVRChannelInfoTag()->IsRadio();
tag->m_iChannelNumber = channel->GetPVRChannelInfoTag()->ChannelNumber();
}
}
else if (setting.id == CONTROL_TMR_DAY && m_tmp_day > 10)
{
CDateTime time = CDateTime::GetCurrentDateTime();
CDateTime timestart = timerStartTime;
CDateTime timestop = timerEndTime;
int m_tmp_diff;
tm time_cur;
tm time_tmr;
/* get diffence of timer in days between today and timer start date */
time.GetAsTm(time_cur);
timestart.GetAsTm(time_tmr);
m_tmp_diff = time_tmr.tm_yday - time_cur.tm_yday;
if (time_tmr.tm_yday - time_cur.tm_yday < 0)
m_tmp_diff = 365;
CDateTime newStart = timestart + CDateTimeSpan(m_tmp_day-11-m_tmp_diff, 0, 0, 0);
CDateTime newEnd = timestop + CDateTimeSpan(m_tmp_day-11-m_tmp_diff, 0, 0, 0);
tag->SetStartFromLocalTime(newStart);
tag->SetEndFromLocalTime(newEnd);
EnableSettings(CONTROL_TMR_FIRST_DAY, false);
tag->m_bIsRepeating = false;
tag->m_iWeekdays = 0;
}
else if (setting.id == CONTROL_TMR_DAY && m_tmp_day <= 10)
{
EnableSettings(CONTROL_TMR_FIRST_DAY, true);
SetTimerFromWeekdaySetting(*tag);
}
else if (setting.id == CONTROL_TMR_BEGIN)
{
if (CGUIDialogNumeric::ShowAndGetTime(timerStartTime, g_localizeStrings.Get(14066)))
{
CDateTime timestart = 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);
timerStartTimeStr = tag->StartAsLocalTime().GetAsLocalizedTime("", false);
UpdateSetting(CONTROL_TMR_BEGIN);
}
}
else if (setting.id == CONTROL_TMR_END)
{
if (CGUIDialogNumeric::ShowAndGetTime(timerEndTime, g_localizeStrings.Get(14066)))
{
CDateTime timestop = timerEndTime;
int start_day = tag->EndAsLocalTime().GetDay();
int start_month = tag->EndAsLocalTime().GetMonth();
int start_year = tag->EndAsLocalTime().GetYear();
int start_hour = timestop.GetHour();
int start_minute = timestop.GetMinute();
CDateTime newEnd(start_year, start_month, start_day, start_hour, start_minute, 0);
tag->SetEndFromLocalTime(newEnd);
timerEndTimeStr = tag->EndAsLocalTime().GetAsLocalizedTime("", false);
UpdateSetting(CONTROL_TMR_END);
}
}
else if (setting.id == CONTROL_TMR_FIRST_DAY && m_tmp_day <= 10)
{
CDateTime newFirstDay;
if (m_tmp_iFirstDay > 0)
//.........这里部分代码省略.........
示例4: CreateSettings
void CGUIDialogPVRTimerSettings::CreateSettings()
{
CPVRTimerInfoTag* tag = m_timerItem->GetPVRTimerInfoTag();
// clear out any old settings
m_settings.clear();
// create our settings controls
m_bTimerActive = tag->IsActive();
AddBool(CONTROL_TMR_ACTIVE, 19074, &m_bTimerActive);
AddButton(CONTROL_TMR_NAME, 19075, &tag->m_strTitle, true);
if (tag->SupportsFolders())
AddButton(CONTROL_TMR_DIR, 19076, &tag->m_strDirectory, true);
AddBool(CONTROL_TMR_RADIO, 19077, &tag->m_bIsRadio);
/// Channel names
{
// For TV
CFileItemList channelslist_tv;
SETTINGSTRINGS channelstrings_tv;
AddChannelNames(channelslist_tv, channelstrings_tv, false);
// For Radio
CFileItemList channelslist_radio;
SETTINGSTRINGS channelstrings_radio;
AddChannelNames(channelslist_radio, channelstrings_radio, true);
}
/// Day
{
SETTINGSTRINGS daystrings;
tm time_cur;
tm time_tmr;
for (unsigned int iDayPtr = 19086; iDayPtr <= 19096; iDayPtr++)
daystrings.push_back(g_localizeStrings.Get(iDayPtr));
CDateTime time = CDateTime::GetCurrentDateTime();
CDateTime timestart = tag->StartAsLocalTime();
/* get diffence of timer in days between today and timer start date */
time.GetAsTm(time_cur);
timestart.GetAsTm(time_tmr);
m_tmp_day += time_tmr.tm_yday - time_cur.tm_yday;
if (time_tmr.tm_yday - time_cur.tm_yday < 0)
m_tmp_day += 365;
for (int i = 1; i < 365; ++i)
{
CStdString string = time.GetAsLocalizedDate();
daystrings.push_back(string);
time += CDateTimeSpan(1, 0, 0, 0);
}
SetWeekdaySettingFromTimer(*tag);
AddSpin(CONTROL_TMR_DAY, 19079, &m_tmp_day, daystrings.size(), daystrings);
}
AddButton(CONTROL_TMR_BEGIN, 19080, &timerStartTimeStr, true);
AddButton(CONTROL_TMR_END, 19081, &timerEndTimeStr, true);
AddSpin(CONTROL_TMR_PRIORITY, 19082, &tag->m_iPriority, 0, 99);
AddSpin(CONTROL_TMR_LIFETIME, 19083, &tag->m_iLifetime, 0, 365);
/// First day
{
SETTINGSTRINGS daystrings;
tm time_cur;
tm time_tmr;
CDateTime time = CDateTime::GetCurrentDateTime();
CDateTime timestart = tag->FirstDayAsLocalTime();
/* get diffence of timer in days between today and timer start date */
if (time < timestart)
{
time.GetAsTm(time_cur);
timestart.GetAsTm(time_tmr);
m_tmp_iFirstDay += time_tmr.tm_yday - time_cur.tm_yday + 1;
if (time_tmr.tm_yday - time_cur.tm_yday < 0)
m_tmp_iFirstDay += 365;
}
daystrings.push_back(g_localizeStrings.Get(19030));
for (int i = 1; i < 365; ++i)
{
CStdString string = time.GetAsLocalizedDate();
daystrings.push_back(string);
time += CDateTimeSpan(1, 0, 0, 0);
}
AddSpin(CONTROL_TMR_FIRST_DAY, 19084, &m_tmp_iFirstDay, daystrings.size(), daystrings);
if (tag->m_bIsRepeating)
EnableSettings(CONTROL_TMR_FIRST_DAY, true);
else
//.........这里部分代码省略.........