本文整理汇总了C++中CDateTime::GetAsLocalizedTime方法的典型用法代码示例。如果您正苦于以下问题:C++ CDateTime::GetAsLocalizedTime方法的具体用法?C++ CDateTime::GetAsLocalizedTime怎么用?C++ CDateTime::GetAsLocalizedTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDateTime
的用法示例。
在下文中一共展示了CDateTime::GetAsLocalizedTime方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateTimeshift
void CPVRGUIInfo::UpdateTimeshift(void)
{
bool bStarted = g_PVRManager.IsStarted();
bool bIsTimeshifting = bStarted && g_PVRClients->IsTimeshifting();
CDateTime tmp;
time_t iTimeshiftStartTime = g_PVRClients->GetBufferTimeStart();
tmp.SetFromUTCDateTime(iTimeshiftStartTime);
std::string strTimeshiftStartTime = tmp.GetAsLocalizedTime("", false);
time_t iTimeshiftEndTime = g_PVRClients->GetBufferTimeEnd();
tmp.SetFromUTCDateTime(iTimeshiftEndTime);
std::string strTimeshiftEndTime = tmp.GetAsLocalizedTime("", false);
time_t iTimeshiftPlayTime = g_PVRClients->GetPlayingTime();
tmp.SetFromUTCDateTime(iTimeshiftPlayTime);
std::string strTimeshiftPlayTime = tmp.GetAsLocalizedTime("", true);
CSingleLock lock(m_critSection);
m_bIsTimeshifting = bIsTimeshifting;
m_iTimeshiftStartTime = iTimeshiftStartTime;
m_iTimeshiftEndTime = iTimeshiftEndTime;
m_iTimeshiftPlayTime = iTimeshiftPlayTime;
m_strTimeshiftStartTime = strTimeshiftStartTime;
m_strTimeshiftEndTime = strTimeshiftEndTime;
m_strTimeshiftPlayTime = strTimeshiftPlayTime;
}
示例2: 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);
}
示例3: GetGuideForChannel
bool CMythDirectory::GetGuideForChannel(const CStdString& base, CFileItemList &items, int channelNumber)
{
cmyth_database_t database = m_session->GetDatabase();
if (!database)
{
CLog::Log(LOGERROR, "%s - Could not get database", __FUNCTION__);
return false;
}
time_t now;
time(&now);
time_t end = now + (24 * 60 * 60); // How many seconds of EPG from now we should grab, 24 hours in seconds
cmyth_program_t *program = NULL;
// TODO: See if there is a way to just get the entries for the chosen channel rather than ALL
int count = m_dll->mysql_get_guide(database, &program, now, end);
CLog::Log(LOGDEBUG, "%s - %i entries in guide data", __FUNCTION__, count);
if (count <= 0)
return false;
for (int i = 0; i < count; i++)
{
if (program[i].channum == channelNumber)
{
CFileItemPtr item(new CFileItem("", false)); // No path for guide entries
/*
* Set the FileItem meta data.
*/
CStdString title = program[i].title; // e.g. Mythbusters
CStdString subtitle = program[i].subtitle; // e.g. The Pirate Special
CDateTime localstart;
if (program[i].starttime)
localstart = CTimeUtils::GetLocalTime(program[i].starttime);
item->m_strTitle = StringUtils::Format("%s - %s",
localstart.GetAsLocalizedTime("HH:mm", false).c_str(),
title.c_str()); // e.g. 20:30 - Mythbusters
if (!subtitle.empty())
item->m_strTitle += " - \"" + subtitle + "\""; // e.g. 20:30 - Mythbusters - "The Pirate Special"
item->m_dateTime = localstart;
/*
* Set the VideoInfoTag meta data so it matches the FileItem meta data where possible.
*/
CVideoInfoTag* tag = item->GetVideoInfoTag();
tag->m_strTitle = title;
if (!subtitle.empty())
tag->m_strTitle += " - \"" + subtitle + "\""; // e.g. Mythbusters - "The Pirate Special"
tag->m_strShowTitle = title;
tag->m_strOriginalTitle = title;
tag->m_strPlotOutline = subtitle;
tag->m_strPlot = program[i].description;
// TODO: Strip out the subtitle from the description if it is present at the start?
// TODO: Do we need to add the subtitle to the start of the plot if not already as it used to? Seems strange, should be handled by skin?
tag->m_genre = StringUtils::Split(program[i].category, g_advancedSettings.m_videoItemSeparator); // e.g. Sports
tag->m_strAlbum = program[i].callsign; // e.g. TV3
CDateTime start(program[i].starttime);
CDateTime end(program[i].endtime);
CDateTimeSpan runtime = end - start;
tag->m_duration = runtime.GetSeconds() + runtime.GetMinutes() * 60 + runtime.GetHours() * 3600;
tag->m_iSeason = 0; // So XBMC treats the content as an episode and displays tag information.
tag->m_iEpisode = 0;
items.Add(item);
}
}
/*
* Items are sorted as added to the list (in ascending date order). Specifying sorting by date can
* result in the guide being shown in the wrong order for skins that sort by date in descending
* order by default with no option to change to ascending, e.g. Confluence.
*/
items.AddSortMethod(SortByNone, 552 /* Date */, LABEL_MASKS("%K", "%J")); // Still leave the date label
m_dll->ref_release(program);
return true;
}
示例4: 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();
}
}
示例5: GetLabel
bool CPlayerGUIInfo::GetLabel(std::string& value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const
{
switch (info.m_info)
{
///////////////////////////////////////////////////////////////////////////////////////////////
// PLAYER_*
///////////////////////////////////////////////////////////////////////////////////////////////
case PLAYER_SEEKOFFSET:
{
std::string seekOffset = StringUtils::SecondsToTimeString(std::abs(m_seekOffset / 1000), static_cast<TIME_FORMAT>(info.GetData1()));
if (m_seekOffset < 0)
value = "-" + seekOffset;
else if (m_seekOffset > 0)
value = "+" + seekOffset;
return true;
}
case PLAYER_VOLUME:
value = StringUtils::Format("%2.1f dB", CAEUtil::PercentToGain(g_application.GetVolume(false)));
return true;
case PLAYER_SUBTITLE_DELAY:
value = StringUtils::Format("%2.3f s", g_application.GetAppPlayer().GetVideoSettings().m_SubtitleDelay);
return true;
case PLAYER_AUDIO_DELAY:
value = StringUtils::Format("%2.3f s", g_application.GetAppPlayer().GetVideoSettings().m_AudioDelay);
return true;
case PLAYER_CHAPTER:
value = StringUtils::Format("%02d", g_application.GetAppPlayer().GetChapter());
return true;
case PLAYER_CHAPTERCOUNT:
value = StringUtils::Format("%02d", g_application.GetAppPlayer().GetChapterCount());
return true;
case PLAYER_CHAPTERNAME:
g_application.GetAppPlayer().GetChapterName(value);
return true;
case PLAYER_PATH:
case PLAYER_FILENAME:
case PLAYER_FILEPATH:
value = item->GetPath();
if (info.m_info == PLAYER_PATH)
{
// do this twice since we want the path outside the archive if this
// is to be of use.
if (URIUtils::IsInArchive(value))
value = URIUtils::GetParentPath(value);
value = URIUtils::GetParentPath(value);
}
else if (info.m_info == PLAYER_FILENAME)
value = URIUtils::GetFileName(value);
return true;
case PLAYER_TITLE:
// use label or drop down to title from path
value = item->GetLabel();
if (value.empty())
value = CUtil::GetTitleFromPath(item->GetPath());
return true;
case PLAYER_PLAYSPEED:
{
float speed = g_application.GetAppPlayer().GetPlaySpeed();
if (speed == 1.0)
speed = g_application.GetAppPlayer().GetPlayTempo();
value = StringUtils::Format("%.2f", speed);
return true;
}
case PLAYER_TIME:
value = GetCurrentPlayTime(static_cast<TIME_FORMAT>(info.GetData1()));
return true;
case PLAYER_START_TIME:
{
const CDateTime time(g_application.GetAppPlayer().GetStartTime());
value = time.GetAsLocalizedTime(static_cast<TIME_FORMAT>(info.GetData1()));
return true;
}
case PLAYER_DURATION:
value = GetDuration(static_cast<TIME_FORMAT>(info.GetData1()));
return true;
case PLAYER_TIME_REMAINING:
value = GetCurrentPlayTimeRemaining(static_cast<TIME_FORMAT>(info.GetData1()));
return true;
case PLAYER_FINISH_TIME:
{
CDateTime time(CDateTime::GetCurrentDateTime());
int playTimeRemaining = GetPlayTimeRemaining();
float speed = g_application.GetAppPlayer().GetPlaySpeed();
float tempo = g_application.GetAppPlayer().GetPlayTempo();
if (speed == 1.0)
playTimeRemaining /= tempo;
time += CDateTimeSpan(0, 0, 0, playTimeRemaining);
value = time.GetAsLocalizedTime(static_cast<TIME_FORMAT>(info.GetData1()));
return true;
}
case PLAYER_TIME_SPEED:
{
float speed = g_application.GetAppPlayer().GetPlaySpeed();
if (speed != 1.0)
value = StringUtils::Format("%s (%ix)", GetCurrentPlayTime(static_cast<TIME_FORMAT>(info.GetData1())).c_str(), static_cast<int>(speed));
else
value = GetCurrentPlayTime(TIME_FORMAT_GUESS);
return true;
}
//.........这里部分代码省略.........
示例6: 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)
//.........这里部分代码省略.........
示例7: Format
static std::string ToSettingTimeFormat(const CDateTime& time, const std::string& timeFormat)
{
return StringUtils::Format(g_localizeStrings.Get(20036).c_str(), time.GetAsLocalizedTime(timeFormat, true).c_str(), timeFormat.c_str());
}
示例8: Update
void CGUIDialogPVRGuideSearch::Update()
{
CGUISpinControlEx *pSpin;
CGUIEditControl *pEdit;
CGUIRadioButtonControl *pRadioButton;
if (!m_searchfilter)
return;
pEdit = (CGUIEditControl *)GetControl(CONTROL_EDIT_SEARCH);
if (pEdit)
{
pEdit->SetLabel2(m_searchfilter->m_strSearchTerm);
pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_TEXT, 16017);
}
pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_CASE_SENS);
if (pRadioButton) pRadioButton->SetSelected(m_searchfilter->m_bIsCaseSensitive);
pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_INC_DESC);
if (pRadioButton) pRadioButton->SetSelected(m_searchfilter->m_bSearchInDescription);
pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_FTA_ONLY);
if (pRadioButton) pRadioButton->SetSelected(m_searchfilter->m_bFTAOnly);
pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_UNK_GENRE);
if (pRadioButton) pRadioButton->SetSelected(m_searchfilter->m_bIncludeUnknownGenres);
pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_IGNORE_REC);
if (pRadioButton) pRadioButton->SetSelected(m_searchfilter->m_bIgnorePresentRecordings);
pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_BTN_IGNORE_TMR);
if (pRadioButton) pRadioButton->SetSelected(m_searchfilter->m_bIgnorePresentTimers);
pRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_SPIN_NO_REPEATS);
if (pRadioButton) pRadioButton->SetSelected(m_searchfilter->m_bPreventRepeats);
/* Set duration list spin */
pSpin = (CGUISpinControlEx *)GetControl(CONTROL_SPIN_MIN_DURATION);
if (pSpin)
{
pSpin->Clear();
pSpin->AddLabel("-", -1);
for (int i = 1; i < 12*60/5; i++)
{
CStdString string;
string.Format(g_localizeStrings.Get(14044),i*5);
pSpin->AddLabel(string, i*5);
}
pSpin->SetValue(m_searchfilter->m_iMinimumDuration);
}
pSpin = (CGUISpinControlEx *)GetControl(CONTROL_SPIN_MAX_DURATION);
if (pSpin)
{
pSpin->Clear();
pSpin->AddLabel("-", -1);
for (int i = 1; i < 12*60/5; i++)
{
CStdString string;
string.Format(g_localizeStrings.Get(14044),i*5);
pSpin->AddLabel(string, i*5);
}
pSpin->SetValue(m_searchfilter->m_iMaximumDuration);
}
/* Set time fields */
pEdit = (CGUIEditControl *)GetControl(CONTROL_EDIT_START_TIME);
if (pEdit)
{
CDateTime time = m_searchfilter->m_startTime;
pEdit->SetLabel2(time.GetAsLocalizedTime("", false));
pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_TIME, 14066);
}
pEdit = (CGUIEditControl *)GetControl(CONTROL_EDIT_STOP_TIME);
if (pEdit)
{
CDateTime time = m_searchfilter->m_endTime;
pEdit->SetLabel2(time.GetAsLocalizedTime("", false));
pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_TIME, 14066);
}
pEdit = (CGUIEditControl *)GetControl(CONTROL_EDIT_START_DATE);
if (pEdit)
{
CDateTime date = m_searchfilter->m_startDate;
pEdit->SetLabel2(date.GetAsDBDate());
pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_DATE, 14067);
}
pEdit = (CGUIEditControl *)GetControl(CONTROL_EDIT_STOP_DATE);
if (pEdit)
{
CDateTime date = m_searchfilter->m_endDate;
pEdit->SetLabel2(date.GetAsDBDate());
pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_DATE, 14067);
}
/* Set Channel list spin */
pSpin = (CGUISpinControlEx *)GetControl(CONTROL_SPIN_CHANNELS);
if (pSpin)
{
//.........这里部分代码省略.........