本文整理汇总了C++中CDateTime::GetAsLocalizedDate方法的典型用法代码示例。如果您正苦于以下问题:C++ CDateTime::GetAsLocalizedDate方法的具体用法?C++ CDateTime::GetAsLocalizedDate怎么用?C++ CDateTime::GetAsLocalizedDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDateTime
的用法示例。
在下文中一共展示了CDateTime::GetAsLocalizedDate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DaysOptionsFiller
void CGUIDialogPVRTimerSettings::DaysOptionsFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t, void *data)
{
if (setting == NULL || data == NULL)
return;
CGUIDialogPVRTimerSettings *dialog = static_cast<CGUIDialogPVRTimerSettings*>(data);
if (dialog == NULL)
return;
const CPVRTimerInfoTag *tag = dialog->m_timerItem->GetPVRTimerInfoTag();
if (tag == NULL)
return;
if (setting->GetId() == SETTING_TMR_DAY)
{
for (unsigned int iDayPtr = 19086; iDayPtr <= 19096; iDayPtr++)
list.push_back(std::make_pair(g_localizeStrings.Get(iDayPtr), list.size()));
}
else if (setting->GetId() == SETTING_TMR_FIRST_DAY)
list.push_back(std::make_pair(g_localizeStrings.Get(19030), 0));
CDateTime time = CDateTime::GetCurrentDateTime();
for (int i = 1; i < 365; ++i)
{
std::string string = time.GetAsLocalizedDate();
list.push_back(std::make_pair(time.GetAsLocalizedDate(), list.size()));
time += CDateTimeSpan(1, 0, 0, 0);
}
}
示例2: SettingOptionsLongDateFormatsFiller
void CLangInfo::SettingOptionsLongDateFormatsFiller(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string ¤t, void *data)
{
bool match = false;
const std::string& longDateFormatSetting = static_cast<const CSettingString*>(setting)->GetValue();
CDateTime now = CDateTime::GetCurrentDateTime();
list.push_back(std::make_pair(StringUtils::Format(g_localizeStrings.Get(20035).c_str(), now.GetAsLocalizedDate(g_langInfo.m_currentRegion->m_strDateFormatLong).c_str()), SETTING_REGIONAL_DEFAULT));
if (longDateFormatSetting == SETTING_REGIONAL_DEFAULT)
{
match = true;
current = SETTING_REGIONAL_DEFAULT;
}
for (size_t i = 0; i < LONG_DATE_FORMATS_SIZE; i++)
{
const std::string& longDateFormat = longDateFormats[i];
list.push_back(std::make_pair(now.GetAsLocalizedDate(longDateFormat), longDateFormat));
if (!match && longDateFormatSetting == longDateFormat)
{
match = true;
current = longDateFormat;
}
}
if (!match && !list.empty())
current = list[0].second;
}
示例3: setDate
void CProfile::setDate()
{
const CDateTime now = CDateTime::GetCurrentDateTime();
std::string strDate = now.GetAsLocalizedDate(false);
std::string strTime = now.GetAsLocalizedTime(TIME_FORMAT_GUESS);
if (strDate.empty() || strTime.empty())
setDate("-");
else
setDate(strDate+" - "+strTime);
}
示例4: DaysFiller
void CGUIDialogPVRTimerSettings::DaysFiller(
const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t, 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");
}
示例5: Update
void CGUIControlRangeSetting::Update(bool updateDisplayOnly /* = false */)
{
if (m_pSlider == NULL ||
m_pSetting->GetType() != SettingTypeList)
return;
CGUIControlBaseSetting::Update();
CSettingList *settingList = static_cast<CSettingList*>(m_pSetting);
const SettingPtrList &settingListValues = settingList->GetValue();
if (settingListValues.size() != 2)
return;
const CSetting *listDefintion = settingList->GetDefinition();
const CSettingControlRange *controlRange = static_cast<const CSettingControlRange*>(m_pSetting->GetControl());
const std::string &controlFormat = controlRange->GetFormat();
std::string strText;
std::string strTextLower, strTextUpper;
std::string formatString = g_localizeStrings.Get(controlRange->GetFormatLabel() > -1 ? controlRange->GetFormatLabel() : 21469);
std::string valueFormat = controlRange->GetValueFormat();
if (controlRange->GetValueFormatLabel() > -1)
valueFormat = g_localizeStrings.Get(controlRange->GetValueFormatLabel());
switch (listDefintion->GetType())
{
case SettingTypeInteger:
{
int valueLower, valueUpper;
if (updateDisplayOnly)
{
valueLower = m_pSlider->GetIntValue(CGUISliderControl::RangeSelectorLower);
valueUpper = m_pSlider->GetIntValue(CGUISliderControl::RangeSelectorUpper);
}
else
{
valueLower = static_cast<CSettingInt*>(settingListValues[0].get())->GetValue();
valueUpper = static_cast<CSettingInt*>(settingListValues[1].get())->GetValue();
m_pSlider->SetIntValue(valueLower, CGUISliderControl::RangeSelectorLower);
m_pSlider->SetIntValue(valueUpper, CGUISliderControl::RangeSelectorUpper);
}
if (controlFormat == "date" || controlFormat == "time")
{
CDateTime dateLower = (time_t)valueLower;
CDateTime dateUpper = (time_t)valueUpper;
if (controlFormat == "date")
{
if (valueFormat.empty())
{
strTextLower = dateLower.GetAsLocalizedDate();
strTextUpper = dateUpper.GetAsLocalizedDate();
}
else
{
strTextLower = dateLower.GetAsLocalizedDate(valueFormat);
strTextUpper = dateUpper.GetAsLocalizedDate(valueFormat);
}
}
else
{
if (valueFormat.empty())
valueFormat = "mm:ss";
strTextLower = dateLower.GetAsLocalizedTime(valueFormat);
strTextUpper = dateUpper.GetAsLocalizedTime(valueFormat);
}
}
else
{
strTextLower = StringUtils::Format(valueFormat.c_str(), valueLower);
strTextUpper = StringUtils::Format(valueFormat.c_str(), valueUpper);
}
if (valueLower != valueUpper)
strText = StringUtils::Format(formatString.c_str(), strTextLower.c_str(), strTextUpper.c_str());
else
strText = strTextLower;
break;
}
case SettingTypeNumber:
{
double valueLower, valueUpper;
if (updateDisplayOnly)
{
valueLower = static_cast<double>(m_pSlider->GetFloatValue(CGUISliderControl::RangeSelectorLower));
valueUpper = static_cast<double>(m_pSlider->GetFloatValue(CGUISliderControl::RangeSelectorUpper));
}
else
{
valueLower = static_cast<CSettingNumber*>(settingListValues[0].get())->GetValue();
valueUpper = static_cast<CSettingNumber*>(settingListValues[1].get())->GetValue();
m_pSlider->SetFloatValue((float)valueLower, CGUISliderControl::RangeSelectorLower);
m_pSlider->SetFloatValue((float)valueUpper, CGUISliderControl::RangeSelectorUpper);
}
strTextLower = StringUtils::Format(valueFormat.c_str(), valueLower);
if (valueLower != valueUpper)
//.........这里部分代码省略.........
示例6: 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
//.........这里部分代码省略.........
示例7: GetLabel
bool CMusicGUIInfo::GetLabel(std::string& value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const
{
if (info.GetData1() && info.m_info >= MUSICPLAYER_TITLE && info.m_info <= MUSICPLAYER_ALBUM_ARTIST)
return GetPlaylistInfo(value, info);
const CMusicInfoTag* tag = item->GetMusicInfoTag();
if (tag)
{
switch (info.m_info)
{
/////////////////////////////////////////////////////////////////////////////////////////////
// PLAYER_* / MUSICPLAYER_* / LISTITEM_*
/////////////////////////////////////////////////////////////////////////////////////////////
case PLAYER_PATH:
case PLAYER_FILENAME:
case PLAYER_FILEPATH:
value = tag->GetURL();
if (value.empty())
value = item->GetPath();
value = GUIINFO::GetFileInfoLabelValueFromPath(info.m_info, value);
return true;
case PLAYER_TITLE:
value = tag->GetTitle();
return !value.empty();
case MUSICPLAYER_TITLE:
value = tag->GetTitle();
if (value.empty())
value = item->GetLabel();
if (value.empty())
value = CUtil::GetTitleFromPath(item->GetPath());
return true;
case LISTITEM_TITLE:
value = tag->GetTitle();
return true;
case MUSICPLAYER_PLAYCOUNT:
case LISTITEM_PLAYCOUNT:
if (tag->GetPlayCount() > 0)
{
value = StringUtils::Format("%i", tag->GetPlayCount());
return true;
}
break;
case MUSICPLAYER_LASTPLAYED:
case LISTITEM_LASTPLAYED:
{
const CDateTime dateTime = tag->GetLastPlayed();
if (dateTime.IsValid())
{
value = dateTime.GetAsLocalizedDate();
return true;
}
break;
}
case MUSICPLAYER_TRACK_NUMBER:
case LISTITEM_TRACKNUMBER:
if (tag->Loaded() && tag->GetTrackNumber() > 0)
{
value = StringUtils::Format("%02i", tag->GetTrackNumber());
return true;
}
break;
case MUSICPLAYER_DISC_NUMBER:
case LISTITEM_DISC_NUMBER:
if (tag->GetDiscNumber() > 0)
{
value = StringUtils::Format("%i", tag->GetDiscNumber());
return true;
}
break;
case MUSICPLAYER_ARTIST:
case LISTITEM_ARTIST:
value = tag->GetArtistString();
return true;
case MUSICPLAYER_ALBUM_ARTIST:
case LISTITEM_ALBUM_ARTIST:
value = tag->GetAlbumArtistString();
return true;
case MUSICPLAYER_CONTRIBUTORS:
case LISTITEM_CONTRIBUTORS:
if (tag->HasContributors())
{
value = tag->GetContributorsText();
return true;
}
break;
case MUSICPLAYER_CONTRIBUTOR_AND_ROLE:
case LISTITEM_CONTRIBUTOR_AND_ROLE:
if (tag->HasContributors())
{
value = tag->GetContributorsAndRolesText();
return true;
}
break;
case MUSICPLAYER_ALBUM:
case LISTITEM_ALBUM:
value = tag->GetAlbum();
return true;
case MUSICPLAYER_YEAR:
case LISTITEM_YEAR:
value = tag->GetYearString();
//.........这里部分代码省略.........