void CLog::Log(ELOG level, const char* file, const char* function, int line, const char* fmt, ...) { char buffer[2048]; va_list args; va_start (args, fmt); vsprintf(buffer, fmt, args); va_end (args); FILE* pFile = fopen(LOG_FILE,"a+"); if(pFile) { if(level <= m_file_log) { if(m_bLog_src_file[level]) fprintf(pFile, "%s: %s() Line %d: ", file, function, line); if(m_bLog_time) fprintf(pFile, "%s %s: ", getDate().c_str(), getTime().c_str()); fprintf(pFile, "%s\n", buffer); } fclose(pFile); ++m_file_log_count[level]; } if(level <= m_console_log) { if(level==ERROR) { if(m_bLog_src_file[level]) fprintf(stderr, "%s: %s() Line %d: ", file, function, line); if(m_bLog_time) fprintf(stderr, "%s %s: ", getDate().c_str(), getTime().c_str()); fprintf(stderr, "%s\n", buffer); } else { if(m_bLog_src_file[level]) printf("%s: %s() Line %d: ", file, function, line); if(m_bLog_time) printf("%s %s: ", getDate().c_str(), getTime().c_str()); printf("%s\n", buffer); } ++m_console_log_count[level]; } }
STATIC RET_T isOutOfDate( TARGET *targ, TARGET *deptarg, bool *outofdate ) /************************************************************************* * Checks if the current target is out of date */ { getDate( targ ); if( targ->existing && targ->attr.existsonly ) { return( RET_SUCCESS ); } getDate( deptarg ); if( targ->existing && deptarg->existing && deptarg->attr.existsonly ) { return( RET_SUCCESS ); } if( dateCmp( targ->date, deptarg->date ) < 0 ) { *outofdate = true; if( Glob.show_offenders ) { PrtMsg( INF | WILL_BE_BUILT_BECAUSE_OF, targ->node.name, deptarg->node.name); } } if( deptarg->error ) { /* one of the targets had an error while being updated * abort now */ return( RET_ERROR ); } if( (!deptarg->attr.recheck && deptarg->cmds_done) || deptarg->backdated ) { *outofdate = true; } return( RET_SUCCESS ); }
void clientTreatment(int sock, int answerPort){ struct sockaddr_in fromAddr; socklen_t fromAddrLen = sizeof fromAddr; char buf[1024]; int bytes_read; while(1) { bytes_read = recvfrom(sock, buf, 1024, 0, (struct sockaddr *)&fromAddr, &fromAddrLen); char display[16] = {0}; inet_ntop(AF_INET, &fromAddr.sin_addr.s_addr, display, sizeof display); buf[bytes_read-1] = '\0'; for (int i = 0; i < 1023; ++i) { if (buf[i] == '\n'){ buf[i] = 0; } } std::string tmp = std::string(buf); if ((buf[0] - '0' >= 3 && buf[0] - '0' <= 5) || (buf[0] - '0' == 8)){ acceptMessage(buf[0] - '0', NULL, NULL, answerPort); }else if(buf[0] - '0' == 6){ std::string from = tmp.substr(2, 24); struct tm time1; strptime(from.c_str(), "%a %b %d %X %Y", &time1); acceptMessage(buf[0] - '0', mktime(&time1), NULL, answerPort); }else if(buf[0] - '0' == 7){ std::string from = tmp.substr(2, 24); struct tm time1; strptime(from.c_str(), "%a %b %d %X %Y", &time1); std::string to = tmp.substr(27, 24); struct tm time2; strptime(from.c_str(), "%a %b %d %X %Y", &time2); acceptMessage(buf[0] - '0', mktime(&time1), mktime(&time2), answerPort); } message msg; msg.type = tmp[0] - '0'; msg.value = tmp.substr(2); msg.value = msg.value.substr(0, msg.value.size() - 1); msg.ip_adress = display; asctime(localtime(&msg.time)); msg.sTime = getDate(); messages.push_back(msg); tmp+=display; tmp+="|"; tmp+=getDate() + "\0"; s_lock.lock(); file.open("log.txt", std::ios::out | std::ios::app ); file << tmp; std::cout << tmp; file.close(); s_lock.unlock(); } }
bool CAsyncLog::shiftFiles() { if (m_sCurDate != getDate()) { m_sLogFilePath=m_sLogBasePath+"_"+getDate()+".log"; m_sCurDate = getDate(); if (m_ofsOutFile.is_open()) { m_ofsOutFile.close(); } } size_t dwFileSize=this->getFileSize(m_sLogFilePath); if (dwFileSize>=m_dwLogFileMaxSize) { if (m_ofsOutFile.is_open()) { m_ofsOutFile.close(); } char szLogFileName[1024]; char szNewLogFileName[1024]; snprintf(szLogFileName,sizeof(szLogFileName),"%s_%s_%u.log",m_sLogBasePath.c_str(),getDate().c_str(),m_uiLogFileNum-1); if (access(szLogFileName, F_OK) == 0) { if (remove(szLogFileName) < 0 ) { snprintf(m_szErrMsg, sizeof(m_szErrMsg),"remove error: errno=%d.",errno); return false; } } for(int i=m_uiLogFileNum-2; i>=0; i--) { if (i == 0) snprintf(szLogFileName,sizeof(szLogFileName),"%s_%s.log",m_sLogBasePath.c_str(),getDate().c_str()); else snprintf(szLogFileName,sizeof(szLogFileName),"%s_%s_%u.log",m_sLogBasePath.c_str(),getDate().c_str(),i); if (access(szLogFileName, F_OK) == 0) { snprintf(szNewLogFileName,sizeof(szNewLogFileName),"%s_%s_%d.log",m_sLogBasePath.c_str(),getDate().c_str(),i+1); if (rename(szLogFileName,szNewLogFileName) < 0 ) { snprintf(m_szErrMsg, sizeof(m_szErrMsg),"rename error:errno=%d.",errno); return false; } } } } return true; }
int main() { int choice, date1 = 0, date2 = 0, temp; printf("Welcome to date comparison program.\n"); do { printf("\nPlease enter choice:\n"); printf("0: Quit\n"); printf("1: Enter date 1\n"); printf("2: Enter date 2\n"); printf("3: Show both dates\n"); printf("4: Compare dates\n"); choice = getInteger(0, 5, 3); switch (choice) { case 1: printf("Please enter date 1:\n"); date1 = getDate(); printf("Entered "); printDate(date1); printf("\n"); break; case 2: printf("Please enter date 2:\n"); date2 = getDate(); printf("Entered "); printDate(date2); printf("\n"); break; case 3: printf("Date 1: "); printDate(date1); printf("\nDate 2: "); printDate(date2); printf("\n"); break; case 4: if (date1 == date2) printf("Dates equivalent.\n"); else if (date1 < date2) printf("Date 1 is earlier.\n"); else printf("Date 2 is earlier.\n"); break; } } while (choice != 0); printf("Goodbye.\n"); return 0; }
void CLog::Log(ELOG level, const char* file, const char* function, int line, const char* fmt, ...) { char buffer[2048]; va_list args; va_start (args, fmt); vsprintf(buffer, fmt, args); va_end (args); if(level <= m_file_log) { FILE* pFile = fopen(LOG_FILE,"a+"); if(pFile) { if(m_bLog_src_file[level]) { /* be more verbose in debug mode */ #ifdef _DEBUG fprintf(pFile, "%s: %s() Line %d: ", file, function, line); #else fprintf(pFile, "%s(): ", function); #endif } if(m_bLog_time) fprintf(pFile, "%s %s: ", getDate().c_str(), getTime().c_str()); if(level==ERROR) fprintf(pFile, "Error: "); fprintf(pFile, "%s\n", buffer); fclose(pFile); } ++m_file_log_count[level]; } if(level <= m_console_log) { if(level==ERROR) { if(m_bLog_src_file[level]) { #ifdef _DEBUG fprintf(stderr, "%s: %s() Line %d: ", file, function, line); #else fprintf(stderr, "%s(): ", function); #endif } if(m_bLog_time) fprintf(stderr, "%s %s: ", getDate().c_str(), getTime().c_str()); fprintf(stderr, "Error: %s\n", buffer); } else { if(m_bLog_src_file[level]) { #ifdef _DEBUG printf("%s: %s() Line %d: ", file, function, line); #else printf("%s(): ", function); #endif } if(m_bLog_time) printf("%s %s: ", getDate().c_str(), getTime().c_str()); printf("%s\n", buffer); } ++m_console_log_count[level]; } }
void CreationState::createToState_base(const Id<StateModel> & originalState) { // make sure the hovered corresponding timenode dont have a date prior to original state date if(getDate(m_parentSM.model(), originalState) < getDate(m_parentSM.model(), hoveredState) ) { auto cmd = new CreateConstraint{ Path<ScenarioModel>{m_scenarioPath}, originalState, hoveredState}; m_dispatcher.submitCommand(cmd); createdConstraints.append(cmd->createdConstraint()); }//else do nothing }
void NaviWriter::initXml(QXmlStreamWriter* xmlStream) { xmlStream->setAutoFormatting(true); xmlStream->writeStartDocument(); xmlStream->writeStartElement("gpx"); xmlStream->writeAttribute("version", "1.0"); xmlStream->writeAttribute("creator", "Deryabin 404"); xmlStream->writeAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance"); xmlStream->writeAttribute("xsi:schemaLocation", "http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"); xmlStream->writeAttribute("time", getDate(flight.timeGps) + "T" + getTime(flight.timeGps) + "Z"); xmlStream->writeStartElement("trk"); xmlStream->writeAttribute("name", getDate(flight.timeGps)); xmlStream->writeStartElement("trkseg"); }
int NDBT_TestSuite::executeOne(Ndb_cluster_connection& con, const char* _tabname, const char* _testname){ if (tests.size() == 0 && explicitTests.size() == 0) { g_err << "Test size == 0 and explicit test size == 0" << endl; return NDBT_FAILED; } char buf[64]; // For timestamp string ndbout << name << " started [" << getDate(buf, sizeof(buf)) << "]" << endl; const NdbDictionary::Table* ptab = NDBT_Tables::getTable(_tabname); if (ptab == NULL) { g_err << "ptab == NULL" << endl; return NDBT_FAILED; } ndbout << "|- " << ptab->getName() << endl; execute(con, ptab, _testname); if (numTestsFail > 0){ return NDBT_FAILED; }else{ return NDBT_OK; } }
int NDBT_TestSuite::reportAllTables(const char* _testname){ int result; char buf[64]; // For timestamp string ndbout << "Completed running test [" << getDate(buf, sizeof(buf)) << "]" << endl; const int totalNumTests = numTestsExecuted; printTestCaseSummary(_testname); ndbout << numTestsExecuted<< " test(s) executed" << endl; ndbout << numTestsOk << " test(s) OK(" <<(int)(((float)numTestsOk/totalNumTests)*100.0) <<"%)" << endl; if(numTestsFail > 0) ndbout << numTestsFail << " test(s) failed(" <<(int)(((float)numTestsFail/totalNumTests)*100.0) <<"%)" << endl; testSuiteTimer.printTotalTime(); if (numTestsExecuted > 0){ if (numTestsFail > 0){ result = NDBT_FAILED; }else{ result = NDBT_OK; } } else { result = NDBT_FAILED; } return result; }
/////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Get a string representation of the time // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// std::wstring dataHandlerTime::getUnicodeString(const imbxUint32 index) const { PUNTOEXE_FUNCTION_START(L"dataHandlerTime::getUnicodeString"); imbxInt32 year, month, day, hour, minutes, seconds, nanoseconds, offsetHours, offsetMinutes; getDate(index, &year, &month, &day, &hour, &minutes, &seconds, &nanoseconds, &offsetHours, &offsetMinutes); std::wostringstream convStream; convStream << std::setfill(L'0'); convStream << std::setw(2) << hour; convStream << std::setw(1) << L":"; convStream << std::setw(2) << minutes; convStream << std::setw(1) << L":"; convStream << std::setw(2) << seconds; convStream << std::setw(1) << L"."; convStream << std::setw(6) << nanoseconds; if(offsetHours != 0 && offsetMinutes != 0) { convStream << std::setw(1) << (offsetHours < 0 ? L"-" : L"+"); convStream << std::setw(2) << labs(offsetHours); convStream << std::setw(1) << L":"; convStream << std::setw(2) << labs(offsetMinutes); } return convStream.str(); PUNTOEXE_FUNCTION_END(); }
void logs_addEvent(char *msg, char *who){ if(!file_exists(logsFileName)) logs_createFile(); // Get the date and hour and allocate memory char *buffer=malloc(sizeof(char)*MAX_BUFFER_SIZE); char *hour=malloc(sizeof(char)*15); char *date=malloc(sizeof(char)*15); getDate(date); getHour(hour); // Shorten message if necessary if(strlen(msg)>MAX_MESSAGE_LEN){ char *shortenMsg=malloc(sizeof(char)*(MAX_MESSAGE_LEN+1)); strncpy(shortenMsg,msg,MAX_MESSAGE_LEN); msg=shortenMsg; strcat(msg,"..."); } // Print to buffer sprintf(buffer,"%-10s %-8s %-8s %s\n",date,hour,who,msg); // Open file and append int fileDes=open(logsFileName,O_WRONLY | O_APPEND); if(fileDes==-1) perror("adicionar evento"); write(fileDes,buffer,strlen(buffer)*sizeof(char)); close(fileDes); }
int NDBT_TestSuite::executeOne(Ndb_cluster_connection& con, const char* _tabname, const char* _testname){ if(tests.size() == 0) return NDBT_FAILED; Ndb ndb(&con, "TEST_DB"); ndb.init(1024); int result = ndb.waitUntilReady(300); // 5 minutes if (result != 0){ g_err << name <<": Ndb was not ready" << endl; return NDBT_FAILED; } ndbout << name << " started [" << getDate() << "]" << endl; const NdbDictionary::Table* ptab = NDBT_Tables::getTable(_tabname); if (ptab == NULL) return NDBT_FAILED; ndbout << "|- " << ptab->getName() << endl; execute(con, &ndb, ptab, _testname); if (numTestsFail > 0){ return NDBT_FAILED; }else{ return NDBT_OK; } }
CLoggerDefaultBackEnd::CLoggerDefaultBackEnd(){ std::string tmpFilePath; tmpFilePath = "Logs/"; tmpFilePath += getDate(); for(int counter = 1; true; counter++){ std::string logFilePathCheck; logFilePathCheck = tmpFilePath; logFilePathCheck += "_"; logFilePathCheck += std::to_string(counter); logFilePathCheck += ".log"; bool doesFileExistCheck = doesFileExist(logFilePathCheck); bool isFileEmptyCheck = isFileEmpty(logFilePathCheck); if((doesFileExistCheck && isFileEmptyCheck) || !doesFileExistCheck){ logFilePath = logFilePathCheck; break; } } }
void parseCommand(char *command) { if (strcmp(command, "help") == 0) { putString("command list:\n"); putString("help -- display available command\n"); putString("clear -- clear the screen\n"); putString("exit -- halt the machine\n"); putString("date -- get date\n"); putString("time -- get time\n"); putString("asc -- load the custom asc program\n"); putString("test -- test program of system calls\n"); } else if (strcmp(command, "clear") == 0) clear(); else if (strcmp(command, "date") == 0) { putString(getDate()); putString("\n"); } else if (strcmp(command, "time") == 0) { putString(getTime()); putString("\n"); } else if (strcmp(command, "asc") == 0) loadSector(22, 2); else if (strcmp(command, "test") == 0) loadSector(24, 3); else if (strcmp(command, "exit") == 0) status = 0; }
newRecordMenu* newNewRecordMenu(int points){ newRecordMenu* menu = (newRecordMenu*)malloc(sizeof(newRecordMenu)); menu->done = 0; menu->points = points; unsigned long day,month,year; getDate(&day,&month,&year); year+=2000; char dayS[15]; char monthS[15]; char yearS[15]; sprintf(dayS, "%lu", day); sprintf(monthS, "%lu", month); sprintf(yearS, "%lu", year); unsigned int len1 = strlen(dayS); unsigned int len2 = strlen(monthS); unsigned int len3 = strlen(yearS); char *result = (char*)malloc(len1+len2+len3+3); memcpy(result, dayS, len1); memcpy(result+len1, " ", 1); memcpy(result+len1+1, monthS, len2); memcpy(result+len1+len2+1, " ", 1); memcpy(result+len1+len2+2, yearS, len3+1);//+1 to copy the null-terminator menu->data = result; menu->nome = ""; menu->fundo = loadBitmap(getPath("newHighscore.bmp")); return menu; }
Variant FirebirdColumn::getValue() { if (isNull()) return Variant(); switch (_var->sqltype & ~1) { case SQL_TEXT: case SQL_VARYING: return getString(); case SQL_SHORT: case SQL_LONG: if (_var->sqlscale == 0) return int64_t(getLong()); return getDouble(); case SQL_INT64: if (_var->sqlscale == 0) return Variant(int64_t(getDouble())); return getDouble(); case SQL_FLOAT: case SQL_DOUBLE: return getDouble(); case SQL_TYPE_DATE: return getDate(); case SQL_TYPE_TIME: return getTime(); default: break; } qWarning("Sqlda::getValue: invalid type: %d", _var->sqltype); return Variant(); }
bool Item::serializeAttr(PropWriteStream& propWriteStream) const { if (isStackable() || isFluidContainer() || isSplash()) { uint8_t _count = getSubType(); propWriteStream.ADD_UCHAR(ATTR_COUNT); propWriteStream.ADD_UCHAR(_count); } if (hasCharges()) { uint16_t _count = getCharges(); propWriteStream.ADD_UCHAR(ATTR_CHARGES); propWriteStream.ADD_USHORT(_count); } if (!isNotMoveable()) { uint16_t _actionId = getActionId(); if (_actionId) { propWriteStream.ADD_UCHAR(ATTR_ACTION_ID); propWriteStream.ADD_USHORT(_actionId); } } const std::string& _text = getText(); if (!_text.empty()) { propWriteStream.ADD_UCHAR(ATTR_TEXT); propWriteStream.ADD_STRING(_text); } const time_t _writtenDate = getDate(); if (_writtenDate > 0) { propWriteStream.ADD_UCHAR(ATTR_WRITTENDATE); propWriteStream.ADD_ULONG(_writtenDate); } const std::string& _writer = getWriter(); if (!_writer.empty()) { propWriteStream.ADD_UCHAR(ATTR_WRITTENBY); propWriteStream.ADD_STRING(_writer); } const std::string& _specialDesc = getSpecialDescription(); if (!_specialDesc.empty()) { propWriteStream.ADD_UCHAR(ATTR_DESC); propWriteStream.ADD_STRING(_specialDesc); } if (hasAttribute(ATTR_ITEM_DURATION)) { uint32_t duration = getDuration(); propWriteStream.ADD_UCHAR(ATTR_DURATION); propWriteStream.ADD_ULONG(duration); } ItemDecayState_t decayState = getDecaying(); if (decayState == DECAYING_TRUE || decayState == DECAYING_PENDING) { propWriteStream.ADD_UCHAR(ATTR_DECAYING_STATE); propWriteStream.ADD_UCHAR(decayState); } return true; }
int FileParse::writeLog(std::vector<KQINFO> &vecKqInfo) { char date[8]=""; char filePath[MAX_PATH]=""; sprintf(filePath,"%s\\kqlog",KsgGetGateway()->GetConfig()->_basedir.c_str()); if(test_log_dir(filePath)) return -1; sprintf(filePath+strlen(filePath),"\\%d",m_termID); if(test_log_dir(filePath)) return -1; sprintf(filePath+strlen(filePath),"\\%s.txt",getDate(date)); FILE *fp = fopen(filePath,"a+"); if(fp == NULL) return -1; char buf[64]=""; std::vector<KQINFO>::iterator iter; std::string timestamp; KSGOSUtil::GetTimestamp(timestamp); for (iter = vecKqInfo.begin();iter != vecKqInfo.end();iter++ ) { sprintf(buf,"collectTime:%s,phyCardID:%s,phyID:%08X,date:%s,time:%s\n",timestamp.c_str(),iter->phyCardID,atol(iter->phyCardID),iter->date,iter->time); fputs(buf,fp); } fclose(fp); return 0; }
void tekOutput::printDate() { QDateTime tmdt = QDateTime::currentDateTime(); appendPlainText(tr("Date:") + getDate(tmdt) + tr("\n") + tr("Time: ")+ getTime(tmdt) + tr("\n")); ensureCursorVisible(); }
void CDateTime::setTimeString(char const * str, char const * * end, bool local) { unsigned year; unsigned month; unsigned day; getDate(year, month, day, false); unsigned hour = readDigits(str, 2); checkChar(str, ':'); unsigned minute = readDigits(str, 2); checkChar(str, ':'); unsigned sec = readDigits(str, 2); unsigned nano = 0; if(*str == '.') { unsigned digits; for(digits = 0; digits < 9; digits++) { char c = *++str; if(!isdigit(c)) break; nano = nano * 10 + (c - '0'); } while(digits++<9) nano *= 10; } if(end) *end = str; set(year, month, day, hour, minute, sec, nano, local); }
void addNewRevenueMovement() { float value; char * title = calloc(1, STRLEN), * description = calloc(1, STRLEN); printf("adding a new Revenue Movement\n"); title = strdup(getString()); printf("inserisci una descrizione\n"); description = strdup(getString()); printf("inserisci il valore della transazione\n"); scanf("%f", &value); getchar(); time_t compact_date = getDate(); struct revenue * newRvenue = malloc(sizeof(struct revenue)); newRvenue->title = strdup(title); newRvenue->description = strdup(description); newRvenue->value = value; newRvenue->date = compact_date; newRvenue->next = firstRevenueMovement; firstRevenueMovement = newRvenue; }
static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) { bool hasNumberType = strlen(getNumber(cell_index->row)) > 0; graphics_context_set_text_color(ctx, GColorBlack); graphics_draw_text(ctx, getName(cell_index->row), fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD), GRect(35, 0, SCREEN_WIDTH - 30, 20), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL); graphics_draw_text(ctx, getDate(cell_index->row), fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(35, 20, SCREEN_WIDTH - 30, 15), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL); if (hasNumberType) graphics_draw_text(ctx, getNumber(cell_index->row), fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD), GRect(35, 35, SCREEN_WIDTH - 30, 20), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL); GBitmap* image; switch (getType(cell_index->row)) { case 1: image = incomingCall; break; case 2: image = outgoingCall; break; default: image = missedCall; break; } graphics_context_set_compositing_mode(ctx, PNG_COMPOSITING_MODE); graphics_draw_bitmap_in_rect(ctx, image, GRect(3, hasNumberType ? 14 : 5, 28, 28)); }
void WriteXml::writeResults(const char* channelType, Loudness::analyser::LoudnessAnalyser& analyser) { xmlFile << "<Program filename=\""; size_t i; for(i = 0; i < srcAudioFilenames.size() - 1; ++i) { xmlFile << srcAudioFilenames.at(i).c_str() << " - "; } xmlFile << srcAudioFilenames.at(i).c_str(); xmlFile << "\" " << printStandard(analyser.getStandard()) << " " << convertValid(analyser.isValidProgram()) << " " << "channelsType=\"" << channelType << "\" " << "date=\"" << getDate() << "\">\n"; xmlFile << "\t<ProgramLoudness " << convertValid(analyser.isIntegratedLoudnessValid()) << ">" << analyser.getIntegratedLoudness() << "</ProgramLoudness>\n"; xmlFile << "\t<LRA " << convertValid(analyser.isIntegratedLoudnessRangeValid()) << ">" << analyser.getIntegratedRange() << "</LRA>\n"; xmlFile << "\t<MaxMomentaryLoudness " << convertValid(analyser.isMomentaryLoudnessValid()) << ">" << analyser.getMomentaryLoudness() << "</MaxMomentaryLoudness>\n"; xmlFile << "\t<MaxShortTermLoudness " << convertValid(analyser.isMaxShortTermLoudnessValid()) << ">" << analyser.getMaxShortTermLoudness() << "</MaxShortTermLoudness>\n"; xmlFile << "\t<MinShortTermLoudness " << convertValid(analyser.isMinShortTermLoudnessValid()) << ">" << analyser.getMinShortTermLoudness() << "</MinShortTermLoudness>\n"; xmlFile << "\t<TruePeak " << convertValid(analyser.isTruePeakValid()) << ">" << analyser.getTruePeakInDbTP() << "</TruePeak>\n"; xmlFile << "\t<MaxShortTermValues>" << writeValues(analyser.getShortTermValues()) << "</MaxShortTermValues>\n"; xmlFile << "\t<TruePeakValues>" << writeValues(analyser.getTruePeakValues()) << "</TruePeakValues>\n"; xmlFile << "</Program>\n"; }
const QVariant StockData::getValueByIndex(std::size_t idx) const { switch(idx) { case 0: return QVariant::fromValue(mName); break; case 1: return QVariant::fromValue(mSymbol); break; case 2: return QVariant::fromValue(getLatestOpeningPrice()); break; case 3: return QVariant::fromValue(getLatestHighestPrice()); break; case 4: return QVariant::fromValue(getLatestLowestPrice()); break; case 5: return QVariant::fromValue(getLatestClosingPrice()); break; // case 6: // return QVariant::fromValue(getLatestSMA200()); // break; case 6: return QVariant::fromValue(getDate()); break; // case 8: // return QVariant::fromValue(mCurrency); // break; default: return QVariant(); } }
/* Prints message passed in to the file log with Date and Timestamp */ void logMessage(char *message){ /* Log File and result for */ FILE *logFile; int result; /* Date and time strings for time-stamping */ char tempDate[50]; char tempTime[50]; memset(&tempDate, 0, sizeof (tempDate)); memset(&tempTime, 0, sizeof (tempTime)); /* * If logFile assignment == NULL * print error to stderr * else * print to logFile * if closing logFile returns End Of File (EOF) error * print error to stderr */ if ((logFile = fopen("ServerLog.txt", "a")) == NULL) perror("File did not open"); else{ fprintf(logFile, "%s %s - %s\n", getDate(tempDate), getTime(tempTime), message); if((result = fclose(logFile)) == EOF){ //close file perror("File failed to close"); } } }
String SensorDs1307::setTime(void) { String message = ""; tmElements_t tm; bool parse=false; bool config=false; // get the date and time the compiler was run if (getDate(__DATE__, &tm) && getTime(__TIME__, &tm)) { parse = true; // and configure the RTC with this info if (write(tm)) { config = true; } } if (parse && config) { message += "SensorDs1307 configured. Time ="; message += __TIME__; message += ", Date ="; message += __DATE__; } else if (parse) { message += "Error: SensorDs1307 communication error."; message += "Details: Please check your circuitry."; } else { message += "Could not parse info from the compiler, Time =\""; message += __TIME__; message += "\", Date =\""; message += __DATE__; message += "\""; } }
Ensemble Distribution::getEnsemble(int iSize) const { std::vector<float> origValues = mEnsemble.getValues(); int numEns = iSize; if(!Global::isValid(iSize)) numEns = origValues.size(); // Create an ensemble by sampling values from the distribution std::vector<std::pair<float, int> > pairs(numEns); // forecast, ensemble index std::vector<float> invs(numEns, Global::MV); for(int i = 0; i < numEns; i++) { float cdf = (float) (i+1)/(numEns+1); float value = getInv(cdf); invs[i] = value; pairs[i] = std::pair<float, int>(origValues[i], i); } // Ensemble members should have the same rank as in the raw ensemble std::sort(pairs.begin(), pairs.end(), Global::sort_pair_first<float, int>()); std::vector<float> values(numEns, Global::MV); for(int i = 0; i < numEns; i++) { int index = pairs[i].second; float value = invs[i]; values[index] = value; } // Set up the ensemble Ensemble ens(values, getVariable()); ens.setInfo(getDate(), getInit(), getOffset(), getLocation(), getVariable()); return ens; }
string Record::getStringValue(string s){ string retValue = ""; if (!( row_int.find(s) == row_int.end()) ) { retValue = to_string(row_int[s] ); return retValue ; } if (!( row_string.find(s) == row_string.end()) ) { retValue = row_string[s] ; return retValue ; } if (!( row_float.find(s) == row_float.end()) ) { retValue = to_string(row_float[s] ); return retValue ; } if (!( row_date.find(s) == row_date.end()) ) { retValue = getDate(row_date[s]) ; return retValue ; } return retValue ; }
// // [-]{CCYY-MM-DD}[TimeZone] // void TimeVal::parseDate() { initParser(); getDate(); parseTimeZone(); validateDateTime(); xmlnormalize(); }