本文整理汇总了C++中LLDate类的典型用法代码示例。如果您正苦于以下问题:C++ LLDate类的具体用法?C++ LLDate怎么用?C++ LLDate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LLDate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: file
void LLAvatarIconIDCache::load ()
{
llinfos << "Loading avatar icon id cache." << llendl;
// build filename for each user
std::string resolved_filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, mFilename);
llifstream file(resolved_filename);
if (!file.is_open())
return;
// add each line in the file to the list
int uuid_len = UUID_STR_LENGTH-1;
std::string line;
while (std::getline(file, line))
{
LLUUID avatar_id;
LLUUID icon_id;
LLDate date;
std::string avatar_id_str = line.substr(0,uuid_len);
std::string icon_id_str = line.substr(uuid_len,uuid_len);
std::string date_str = line.substr(uuid_len*2, line.length()-uuid_len*2);
if(!avatar_id.set(avatar_id_str) || !icon_id.set(icon_id_str) || !date.fromString(date_str))
continue;
LLAvatarIconIDCacheItem item = {icon_id,date};
mCache[avatar_id] = item;
}
file.close();
}
示例3: LL_WARNS
//static
void LLFloaterBlacklist::addEntry(LLUUID key, LLSD data)
{
if(key.notNull())
{
if(!data.has("entry_type"))
LL_WARNS("FloaterBlacklistAdd") << "addEntry called with no entry type, specify LLAssetType::Etype" << LL_ENDL;
else if(!data.has("entry_name"))
LL_WARNS("FloaterBlacklistAdd") << "addEntry called with no entry name, specify the name that should appear in the listing for this entry." << LL_ENDL;
else
{
if(!data.has("entry_date"))
{
LLDate* curdate = new LLDate(time_corrected());
std::string input_date = curdate->asString();
input_date.replace(input_date.find("T"),1," ");
input_date.resize(input_date.size() - 1);
data["entry_date"] = input_date;
}
if(data["entry_type"].asString() == "1")
{
//remove sounds
LLUUID sound_id=LLUUID(key);
gVFS->removeFile(sound_id,LLAssetType::AT_SOUND);
std::string wav_path= gDirUtilp->getExpandedFilename(LL_PATH_CACHE,sound_id.asString()) + ".dsf";
if(LLAPRFile::isExist(wav_path, LL_APR_RPB))
LLAPRFile::remove(wav_path);
gAudiop->removeAudioData(sound_id);
}
blacklist_entries.insert(std::pair<LLUUID,LLSD>(key,data));
updateBlacklists();
}
}
else
LL_WARNS("FloaterBlacklistAdd") << "addEntry called with a null entry key, please specify LLUUID of asset." << LL_ENDL;
}
示例4: getURL
void LLNotification::init(const std::string& template_name, const LLSD& form_elements)
{
mTemplatep = LLNotifications::instance().getTemplate(template_name);
if (!mTemplatep) return;
// add default substitutions
// TODO: change this to read from the translatable strings file!
mSubstitutions["SECOND_LIFE"] = "Second Life";
mSubstitutions["_URL"] = getURL();
mSubstitutions["_NAME"] = template_name;
// TODO: something like this so that a missing alert is sensible:
//mSubstitutions["_ARGS"] = get_all_arguments_as_text(mSubstitutions);
mForm = LLNotificationFormPtr(new LLNotificationForm(*mTemplatep->mForm));
mForm->append(form_elements);
// apply substitution to form labels
mForm->formatElements(mSubstitutions);
LLDate rightnow = LLDate::now();
if (mTemplatep->mExpireSeconds)
{
mExpiresAt = LLDate(rightnow.secondsSinceEpoch() + mTemplatep->mExpireSeconds);
}
if (mPriority == NOTIFICATION_PRIORITY_UNSPECIFIED)
{
mPriority = mTemplatep->mPriority;
}
}
示例5: stream
void date_test_object_t::test<3>()
{
LLDate date;
std::istringstream stream(VALID_DATE);
std::string expected_string = VALID_DATE;
date.fromStream(stream);
ensure_equals("fromStream failed", date.asString(), expected_string);
}
示例6:
void date_test_object_t::test<2>()
{
#if LL_DATE_PARSER_CHECKS_BOUNDARY
LLDate date;
std::string expected_string;
bool result;
result = date.fromString(INVALID_DATE_24HOUR_BOUNDARY);
ensure_equals("INVALID_DATE_24HOUR_BOUNDARY should have failed" , result, false);
ensure_equals("INVALID_DATE_24HOUR_BOUNDARY date still set to old value on failure!" , date.secondsSinceEpoch(), 0);
result = date.fromString(INVALID_DATE_LEAP);
ensure_equals("INVALID_DATE_LEAP should have failed" , result, false);
result = date.fromString(INVALID_DATE_HOUR);
ensure_equals("INVALID_DATE_HOUR should have failed" , result, false);
result = date.fromString(INVALID_DATE_MIN);
ensure_equals("INVALID_DATE_MIN should have failed" , result, false);
result = date.fromString(INVALID_DATE_SEC);
ensure_equals("INVALID_DATE_SEC should have failed" , result, false);
result = date.fromString(INVALID_DATE_YEAR);
ensure_equals("INVALID_DATE_YEAR should have failed" , result, false);
result = date.fromString(INVALID_DATE_MONTH);
ensure_equals("INVALID_DATE_MONTH should have failed" , result, false);
result = date.fromString(INVALID_DATE_DAY);
ensure_equals("INVALID_DATE_DAY should have failed" , result, false);
#endif
}
示例7: fromLLSD
void LLAvatarName::fromLLSD(const LLSD& sd)
{
mUsername = sd[USERNAME].asString();
mDisplayName = sd[DISPLAY_NAME].asString();
mLegacyFirstName = sd[LEGACY_FIRST_NAME].asString();
mLegacyLastName = sd[LEGACY_LAST_NAME].asString();
mIsDisplayNameDefault = sd[IS_DISPLAY_NAME_DEFAULT].asBoolean();
LLDate expires = sd[DISPLAY_NAME_EXPIRES];
mExpires = expires.secondsSinceEpoch();
LLDate next_update = sd[DISPLAY_NAME_NEXT_UPDATE];
mNextUpdate = next_update.secondsSinceEpoch();
}
示例8: dateFromPDTString
bool LLDateUtil::dateFromPDTString(LLDate& date, const std::string& str)
{
S32 month, day, year;
S32 matched = sscanf(str.c_str(), "%d/%d/%d", &month, &day, &year);
if (matched != 3) return false;
date.fromYMDHMS(year, month, day);
F64 secs_since_epoch = date.secondsSinceEpoch();
// Correct for the fact that specified date is in Pacific time, == UTC - 8
secs_since_epoch += 8.0 * 60.0 * 60.0;
date.secondsSinceEpoch(secs_since_epoch);
return true;
}
示例9: v
void SDTestObject::test<7>()
// Test assignment and casting to various scalar types. These
// assignments should invoke the right conversion without it being
// mentioned explicitly. The few exceptions are marked SAD.
{
SDCleanupCheck check;
LLSD v(" 42.375");
bool b = false;
b = v; ensure_equals("assign to bool", b, true);
b = (bool)v; ensure_equals("cast to bool", b, true);
int i = 99;
i = v; ensure_equals("assign to int", i, 42);
i = (int)v; ensure_equals("cast to int", i, 42);
double d = 3.14159;
d = v; ensure_equals("assign to double", d, 42.375);
d = (double)v; ensure_equals("cast to double", d, 42.375);
std::string s = "yo";
// SAD s = v; ensure_equals("assign to string", s, " 42.375");
s = (std::string)v; ensure_equals("cast to string", s, " 42.375");
std::string uuidStr = "b1e50c2b-b627-4d23-8a86-a65d97b6319b";
v = uuidStr;
LLUUID u;
u = v;
ensure_equals("assign to LLUUID", u, LLUUID(uuidStr));
// SAD u = (LLUUID)v;
// ensure_equals("cast to LLUUID", u, LLUUID(uuidStr));
std::string dateStr = "2005-10-24T15:00:00Z";
v = dateStr;
LLDate date;
date = v;
ensure_equals("assign to LLDate", date.asString(), dateStr);
// SAD date = (LLDate)v;
// ensure_equals("cast to LLDate", date.asString(), dateStr);
std::string uriStr = "http://secondlife.com";
v = uriStr;
LLURI uri;
uri = v;
ensure_equals("assign to LLURI", uri.asString(), uriStr);
// SAD uri = (LLURI)v;
// ensure_equals("cast to LLURI", uri.asString(), uriStr);
}
示例10: LLDate
void FSWSAssetBlacklist::addNewItemToBlacklist(LLUUID id, std::string name, std::string region, LLAssetType::EType type, bool save)
{
LLDate curdate = LLDate(time_corrected());
std::string input_date = curdate.asString();
input_date.replace(input_date.find("T"),1," ");
input_date.resize(input_date.size() - 1);
LLSD data;
data["asset_name"] = name;
data["asset_region"] = region;
data["asset_type"] = type;
data["asset_date"] = input_date;
addNewItemToBlacklistData(LLUUID::generateNewID(id.asString() + "hash"), data, save);
}
示例11: LLDate
void FSWSAssetBlacklist::addNewItemToBlacklist(const LLUUID& id, const std::string& name, const std::string& region, LLAssetType::EType type, bool save)
{
if (isBlacklisted(id, type))
{
return;
}
LLDate curdate = LLDate(time_corrected());
std::string input_date = curdate.asString();
input_date.replace(input_date.find("T"), 1, " ");
input_date.resize(input_date.size() - 1);
LLSD data;
data["asset_name"] = name;
data["asset_region"] = region;
data["asset_type"] = type;
data["asset_date"] = input_date;
addNewItemToBlacklistData(id, data, save);
}
示例12: addCookie
/////////////////////////////////////////////////////////////////////////////////////////
// static
void LLViewerMedia::addCookie(const std::string &name, const std::string &value, const std::string &domain, const LLDate &expires, const std::string &path, bool secure)
{
std::stringstream cookie;
cookie << name << "=" << LLPluginCookieStore::quoteString(value);
if(expires.notNull())
{
cookie << "; expires=" << expires.asRFC1123();
}
cookie << "; domain=" << domain;
cookie << "; path=" << path;
if(secure)
{
cookie << "; secure";
}
getCookieStore()->setCookies(cookie.str());
}
示例13: getURL
void LLNotification::init(const std::string& template_name, const LLSD& form_elements)
{
mTemplatep = LLNotificationTemplates::instance().getTemplate(template_name);
if (!mTemplatep) return;
const LLStringUtil::format_map_t& default_args = LLTrans::getDefaultArgs();
for (LLStringUtil::format_map_t::const_iterator iter = default_args.begin();
iter != default_args.end(); ++iter)
{
mSubstitutions[iter->first] = iter->second;
}
mSubstitutions["_URL"] = getURL();
mSubstitutions["_NAME"] = template_name;
// TODO: something like this so that a missing alert is sensible:
//mSubstitutions["_ARGS"] = get_all_arguments_as_text(mSubstitutions);
mForm = LLNotificationFormPtr(new LLNotificationForm(*mTemplatep->mForm));
mForm->append(form_elements);
// apply substitution to form labels
mForm->formatElements(mSubstitutions);
mIgnored = mForm->getIgnored();
LLDate rightnow = LLDate::now();
if (mTemplatep->mExpireSeconds)
{
mExpiresAt = LLDate(rightnow.secondsSinceEpoch() + mTemplatep->mExpireSeconds);
}
if (mPriority == NOTIFICATION_PRIORITY_UNSPECIFIED)
{
mPriority = mTemplatep->mPriority;
}
}
示例14: getURL
void LLNotification::init(const std::string& template_name, const LLSD& form_elements)
{
mTemplatep = LLNotifications::instance().getTemplate(template_name);
if (!mTemplatep) return;
// add default substitutions
mSubstitutions["[SECOND_LIFE]"] = LLNotifications::instance().getGlobalString("SECOND_LIFE");
mSubstitutions["[VIEWER_NAME]"] = LLNotifications::instance().getGlobalString("VIEWER_NAME");
mSubstitutions["[VIEWER_SITE]"] = LLNotifications::instance().getGlobalString("VIEWER_SITE");
mSubstitutions["[GRID_NAME]"] = gHippoGridManager->getConnectedGrid()->getGridName();
mSubstitutions["[GRID_SITE]"] = gHippoGridManager->getConnectedGrid()->getWebSite();
mSubstitutions["[CURRENCY]"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol();
mSubstitutions["_URL"] = getURL();
mSubstitutions["_NAME"] = template_name;
// TODO: something like this so that a missing alert is sensible:
//mSubstitutions["_ARGS"] = get_all_arguments_as_text(mSubstitutions);
mForm = LLNotificationFormPtr(new LLNotificationForm(*mTemplatep->mForm));
mForm->append(form_elements);
// apply substitution to form labels
mForm->formatElements(mSubstitutions);
LLDate rightnow = LLDate::now();
if (mTemplatep->mExpireSeconds)
{
mExpiresAt = LLDate(rightnow.secondsSinceEpoch() + mTemplatep->mExpireSeconds);
}
if (mPriority == NOTIFICATION_PRIORITY_UNSPECIFIED)
{
mPriority = mTemplatep->mPriority;
}
}
示例15: 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");
}