int CDateTime::compare(CDateTime const & cdt, bool compareNanosec) const { time_t thisSimple = getSimple(); time_t thatSimple = cdt.getSimple(); if(thisSimple != thatSimple) return ((thisSimple > thatSimple) ? +1 : -1); if(compareNanosec && (nanosec != cdt.nanosec)) return ((nanosec > cdt.nanosec) ? +1 : -1); return 0; }
void LLComboBox::onCommit() { if (mAllowTextEntry && getCurrentIndex() != -1) { // we have selected an existing item, blitz the manual text entry with // the properly capitalized item mTextEntry->setValue(getSimple()); mTextEntry->setTentative(FALSE); } LLUICtrl::onCommit(); }
StringBuffer & CDateTime::getDateString(StringBuffer & str, bool local) const { if(isNull()) return str; char buff[64]; // allow extra for invalid dates if(local) { time_t simple = getSimple(); struct tm local; localtime_r(&simple, &local); sprintf(buff, "%04d-%02d-%02d", local.tm_year+1900, local.tm_mon+1, local.tm_mday); } else sprintf(buff, "%04d-%02d-%02d", utc_year+1900, utc_mon+1, utc_mday); return str.append(buff); }
void LLSearchComboBox::onSelectionCommit() { std::string search_query = getSimple(); LLStringUtil::trim(search_query); // Order of add() and mTextEntry->setText does matter because add() will select first item // in drop down list and its label will be copied to text box rewriting mTextEntry->setText() call if(!search_query.empty()) { remove(search_query); add(search_query, ADD_TOP); } mTextEntry->setText(search_query); setControlValue(search_query); }
void LLComboBox::onCommit() { if (mAllowTextEntry && getCurrentIndex() != -1) { // we have selected an existing item, blitz the manual text entry with // the properly capitalized item mTextEntry->setValue(getSimple()); mTextEntry->setTentative(FALSE); } // This line makes the Communicate flyout button context menu require // two clicks to activate correctly. I'm not sure why it was added // in the first place. -- TS //setControlValue(getValue()); LLUICtrl::onCommit(); }
StringBuffer & CDateTime::getTimeString(StringBuffer & str, bool local) const { if(isNull()) return str; char buff[64]; // allow extra for invalid dates char * finger = buff; if(local) { time_t simple = getSimple(); struct tm local; localtime_r(&simple, &local); finger += sprintf(finger, "%02d:%02d:%02d", local.tm_hour, local.tm_min, local.tm_sec); } else finger += sprintf(finger, "%02d:%02d:%02d", utc_hour, utc_min, utc_sec); if(nanosec) finger += sprintf(finger, ".%06u", nanosec/1000); return str.append(buff); }
void CDateTime::getDate(unsigned & year, unsigned & month, unsigned & day, bool local) const { if(local) { time_t simple = getSimple(); struct tm local; localtime_r(&simple, &local); year = local.tm_year + 1900; month = local.tm_mon + 1; day = local.tm_mday; } else { year = utc_year + 1900; month = utc_mon + 1; day = utc_mday; } }
void CDateTime::getTime(unsigned & hour, unsigned & minute, unsigned & second, unsigned & nano, bool local) const { if(local) { time_t simple = getSimple(); struct tm local; localtime_r(&simple, &local); hour = local.tm_hour; minute = local.tm_min; second = local.tm_sec; } else { hour = utc_hour; minute = utc_min; second = utc_sec; } nano = nanosec; }
bool CDateTime::equals(CDateTime const & cdt, bool compareNanosec) const { time_t thisSimple = getSimple(); time_t thatSimple = cdt.getSimple(); return ((thisSimple == thatSimple) && ((compareNanosec) ? (nanosec == cdt.nanosec) : true)); }
void CDateTime::adjustTime(int deltaMins) { time_t simple = getSimple(); simple += deltaMins * 60; set(simple); }