本文整理汇总了C++中LLDate::split方法的典型用法代码示例。如果您正苦于以下问题:C++ LLDate::split方法的具体用法?C++ LLDate::split怎么用?C++ LLDate::split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLDate
的用法示例。
在下文中一共展示了LLDate::split方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getTimestamp
std::string LLTeleportHistoryFlatItem::getTimestamp()
{
const LLDate &date = mDate;
std::string timestamp = "";
LLDate now = LLDate::now();
S32 now_year, now_month, now_day, now_hour, now_min, now_sec;
now.split(&now_year, &now_month, &now_day, &now_hour, &now_min, &now_sec);
const S32 seconds_in_day = 24 * 60 * 60;
S32 seconds_today = now_hour * 60 * 60 + now_min * 60 + now_sec;
S32 time_diff = (S32) now.secondsSinceEpoch() - (S32) date.secondsSinceEpoch();
// Only show timestamp for today and yesterday
if(time_diff < seconds_today + seconds_in_day)
{
timestamp = "[" + LLTrans::getString("TimeHour12")+"]:["
+ LLTrans::getString("TimeMin")+"] ["+ LLTrans::getString("TimeAMPM")+"]";
LLSD substitution;
substitution["datetime"] = (S32) date.secondsSinceEpoch();
LLStringUtil::format(timestamp, substitution);
}
return timestamp;
}
示例2: ageFromDate
std::string LLDateUtil::ageFromDate(const LLDate& born_date, const LLDate& now)
{
S32 born_month, born_day, born_year;
// explode out to month/day/year again
born_date.split(&born_year, &born_month, &born_day);
S32 now_year, now_month, now_day;
now.split(&now_year, &now_month, &now_day);
// Do grade-school subtraction, from right-to-left, borrowing from the left
// when things go negative
S32 age_days = (now_day - born_day);
if (age_days < 0)
{
now_month -= 1;
if (now_month == 0)
{
now_year -= 1;
now_month = 12;
}
age_days += days_from_month(now_year, now_month);
}
S32 age_months = (now_month - born_month);
if (age_months < 0)
{
now_year -= 1;
age_months += 12;
}
S32 age_years = (now_year - born_year);
// Noun pluralization depends on language
std::string lang = LLUI::getLanguage();
// Try for age in round number of years
LLStringUtil::format_map_t args;
if (age_months > 0 || age_years > 0)
{
args["[AGEYEARS]"] =
LLTrans::getCountString(lang, "AgeYears", age_years);
args["[AGEMONTHS]"] =
LLTrans::getCountString(lang, "AgeMonths", age_months);
// We want to display times like:
// 2 year 2 months
// 2 years (implicitly 0 months)
// 11 months
if (age_years > 0)
{
if (age_months > 0)
{
return LLTrans::getString("YearsMonthsOld", args);
}
else
{
return LLTrans::getString("YearsOld", args);
}
}
else // age_years == 0
{
return LLTrans::getString("MonthsOld", args);
}
}
// you're 0 months old, display in weeks or days
// Now for age in weeks
S32 age_weeks = age_days / 7;
age_days = age_days % 7;
if (age_weeks > 0)
{
args["[AGEWEEKS]"] =
LLTrans::getCountString(lang, "AgeWeeks", age_weeks);
return LLTrans::getString("WeeksOld", args);
}
// Down to days now
if (age_days > 0)
{
args["[AGEDAYS]"] =
LLTrans::getCountString(lang, "AgeDays", age_days);
return LLTrans::getString("DaysOld", args);
}
return LLTrans::getString("TodayOld");
}