void menuDeleteFlight(char* passMsg) { Flight flight = { NULL, NULL, 0, 0 }; programHeader(); printf("Usuwanie lotu:\n\n"); if (_inputFlight(&flight)) { if (flight.from == NULL) { sprintf(passMsg, "Nie mozna usunac lotu. Lotnisko wylotu nie istnieje w bazie.\n"); } if (flight.to == NULL) { sprintf(passMsg, "Nie mozna usunac lotu. Lotnisko przylotu nie istnieje w bazie.\n"); } else { Flight* ref = findFlightByAllData(DB_HANDLE, flight.from, flight.to, flight.departure, flight.duration); if (ref == NULL) { sprintf(passMsg, "Nie mozna usunac lotu. Lot z (%s, %s) do (%s, %s) o %hu:%02hu nie istnieje.\n", flight.from->name, flight.from->country, flight.to->name, flight.to->country, getHour(&flight.departure), getMinutes(&flight.departure)); } else { removeFlight(DB_HANDLE, ref); sprintf(passMsg, "Lot z (%s, %s) do (%s, %s) o %hu:%02hu zostal usuniety.\n", flight.from->name, flight.from->country, flight.to->name, flight.to->country, getHour(&flight.departure), getMinutes(&flight.departure)); } } } else { sprintf(passMsg, "Nie mozna usunac lotu. Niepoprawne/niepelne dane.\n"); } menuPrintAllFlights(passMsg); }
void delaySec(int secs){ int start_time = 3600*getHour()+60*getMin()+getSec(); int time2 = start_time; while(time2 <= start_time+secs){ time2 = 3600*getHour()+60*getMin()+getSec(); } }
bool Settings::isTime() { int bh=0, bm=0, eh=0, em=0; getHour(eggBegin,bh,bm); getHour(eggEnd,eh,em); //qDebug()<<QString("Begin: %1:%2").arg(bh).arg(bm); //qDebug()<<QString("End: %1:%2").arg(eh).arg(em); if(QTime(bh,bm) <= QTime::currentTime() && QTime::currentTime() <= QTime(eh,em)) return true; else return false; }
void NDateTime::addHours(const nint hours) { nint _hours = hours; while (getHour() * _hours > 23) { _hours -= 24; addDays(1); } while (getHour() + _hours < 0) { _hours += 24; addDays(-1); } m_Time.addHours(_hours); }
/* * Given a time, opens the appropriate Berkeley DB database--creating it if it * doesn't exist, along with any directories in its path--and sets its record * number to the appropriate value (1 for new databases, last record number + 1 * for existing databases). */ std::tr1::unordered_map <uint32_t, _BerkeleyDB*>::iterator BerkeleyDB::createDatabase(const uint32_t &hourStartTime) { std::string dataFileName = getDataDirectory(hourStartTime); std::tr1::unordered_map <uint32_t, _BerkeleyDB*>::iterator databaseItr; if (!makeDirectory(dataFileName, 0755)) { return databases.end(); } databaseItr = databases.insert(std::make_pair(hourStartTime, new _BerkeleyDB)).first; dataFileName += _baseFileName + '_' + getHour(hourStartTime); if (db_create(&(databaseItr -> second -> database), NULL, 0) != 0) { return databases.end(); } if (databaseItr -> second -> database -> open(databaseItr -> second -> database, NULL, dataFileName.c_str(), NULL, DB_RECNO, DB_CREATE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) != 0) { return databases.end(); } if (databaseItr -> second -> database -> cursor(databaseItr -> second -> database, NULL, &(databaseItr -> second -> cursor), 0) != 0) { return databases.end(); } if (databaseItr -> second -> cursor -> c_get(databaseItr -> second -> cursor, &(databaseItr -> second -> key), &(databaseItr -> second -> data), DB_LAST) == DB_NOTFOUND) { databaseItr -> second -> recordNumber = 1; } else { databaseItr -> second -> recordNumber = *(uint32_t*)databaseItr -> second -> key.data + 1; } databaseItr -> second -> cursor -> c_close(databaseItr -> second -> cursor); return databaseItr; }
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); }
void AGTime::setHour(int h) { if (0 <= h && h < 24) { sec -= 3600 * getHour(); sec += 3600 * h; } }
std::string TTime::toString(){ char buffer [8]; sprintf (buffer, "%.2i:%.2i:%.2i", getHour(), getMin(), getSec()); std::string ret = buffer; return ret; }
/*! * \brief UTCからローカル時間に変換 */ void DateTime::toLocal() { #if defined(_WINDOWS) TIME_ZONE_INFORMATION timeZone; GetTimeZoneInformation(&timeZone); int32_t bias = -timeZone.Bias / 60; #else struct timezone tz; gettimeofday(nullptr, &tz); int32_t bias = -tz.tz_minuteswest / 60; #endif struct tm tm; tm.tm_year = getYear() - 1900; tm.tm_mon = getMonth() - 1; tm.tm_mday = getDay(); tm.tm_hour = getHour() + bias; tm.tm_min = getMinute(); tm.tm_sec = getSecond(); tm.tm_yday = tm.tm_wday = tm.tm_isdst = 0; #if defined(_WINDOWS) time_t time = mktime(&tm); #else time_t time = mktime(&tm); // time_t time = timegm(&tm); #endif struct tm* tmLocal = localtime(&time); toValue(tmLocal, getMilliSecond()); }
// Software Initialization: // input parameter: // void : nothing // return type: // int : return SUCCESS, init Software int init(void) { int level; double actual, desired; char sensorTempData[5]; initLogging("temp_log"); initCSVFile("temp_csv"); initConfigFile("temp_config"); logging(INFO, "\nStarting CliConWARE Software...."); // Printing current hour: printf(" -- Current hour : %d:%02d\n", getHour(), getMin()); // Printing actual temperature: readData("/dev/temp_sensor", sensorTempData); actual = (double) atof(sensorTempData)/ 1000; printf(" -- Actual temperature : %.2f°C\n", actual); // Printing desired temperature: desired = getDesired("temp_config"); printf(" -- Desired temperature : %.2f°C\n", desired); // Printing current knob level: level = map(actual); printf(" -- Current knob level : %d\n", level); logging(INFO, "The Software will start in 3 seconds.....\n"); sleep(3); return SUCCESS; }
SnapshotHeader* getSnapshotHeader(void) { hdr.data.time = getHour(); hdr.data.num_of_data_points = NUMBER_OF_ENTRIES; hdr.data.latest_data_point_index = ramBufferIndex; return &hdr; }
void print_time(time_t tim) { std::cout << getWeekday(tim) << std::endl; std::cout << getSec(tim) << std::endl; std::cout << getMin(tim) << std::endl; std::cout << getHour(tim) << std::endl; std::cout << getYear(tim) << std::endl; std::cout << getDay(tim) << std::endl; std::cout << getMonth(tim) << std::endl; }
double ossimLocalTm::getJulian()const { int J = getMonth(); int K = getDay(); int I = getYear(); return (K-32075+1461*(I+4800+(J-14)/12)/4+367*(J-2-(J-14)/12*12) /12-3*((I+4900+(J-14)/12)/100)/4+ (getHour()/24.0)+ (getMin()/1440.0)+ ((getSec()+theFractionalSecond)/86400.0)); }
/*! * \brief 日付時間をミリ秒に変換 */ int64_t DateTime::toMilliSeconds() const { enum { January = 0, February = January + 31, March = February + 28, April = March + 31, May = April + 30, June = May + 31, July = June + 30, August = July + 31, September = August + 31, October = September + 30, November = October + 31, December = November + 30, }; static const int64_t daySpan[] = { January, February, March, April, May, June, July, August, September, October, November, December, }; int64_t y = getYear(); int64_t m = getMonth(); int64_t d = getDay(); int64_t dy = (y - 1) * 365; // 年数分の日数 int64_t dl = (y / 4) - (y / 100) + (y / 400); // 閏年分の日数 int64_t dm = daySpan[m - 1]; // 1月1日からm月1日までの日数 int64_t result = dy + dl + dm + d - 1; result = (result * 24 * 60 * 60 * 1000) + (getHour() * 60 * 60 * 1000) + (getMinute() * 60 * 1000) + (getSecond() * 1000) + getMilliSecond(); return result; }
void ClockBasic::display(SmartMatrix *matrix) { char temp[3]; if(update()) { temp[0] = '0'; matrix->setRotation(rotation0); matrix->fillScreen({0x00,0x00,0x00}); matrix->fillRoundRectangle(0, 1, matrix->getScreenWidth()-1, matrix->getScreenHeight()-1, 3, {0xFF,0x00,0xFF}, {0x00,0x00,0x00} ); matrix->drawFastVLine(15,5,6,{0xEF,0xCF,0xEF}); matrix->drawFastVLine(16,5,6,{0xEF,0xCF,0xEF}); matrix->drawFastVLine(15,10,11,{0xEF,0xCF,0xEF}); matrix->drawFastVLine(16,10,11,{0xEF,0xCF,0xEF}); // Set font type matrix->setFont(font8x13); //3x5 5x7 6x10 8x13 // Draw Hours getHour(temp); if(temp[0] == ' ') { temp[0] = temp[1]; // replace the space with the number and temp[1] = NULL; matrix->drawString( 7, 2, {0xFF,0xFF,0xFF}, temp); } else { matrix->drawString( 0, 2, {0xFF,0xFF,0xFF}, temp); } // Draw Minutes getMinute(temp); if(temp[0] == ' ') { temp[0] = '0'; } matrix->drawString( 16, 2, {0xFF,0xFF,0xFF}, temp); matrix->swapBuffers(true); } }
int modificarVuelo(ArrayList* vuelos,ArrayList* aviones) { int idVuelo,salida=1; eVuelo* vuelo; int retorno=-1; if(aviones != NULL && vuelos != NULL) { while(getInt(&idVuelo,"Ingresar Numero de Vuelo: ","ERROR",0,9999) == -1); idVuelo=buscarIdVuelo(vuelos,idVuelo); if( idVuelo != -1) { vuelo=vuelos->get(vuelos,idVuelo); if(vuelos != NULL) { while(getString(vuelo->origen,"Ingresar Origen: ","ERROR",0,50) == -1); while(getString(vuelo->destino,"Ingresar Destino: ","ERROR",0,50)== -1); while(getHour(vuelo,"Ingrese Hora de Salida (HH:MM) : ","ERROR",1)== -1); while(getHour(vuelo,"Ingrese Hora de Llegada (HH:MM) : ","ERROR",0)== -1); while(getString(vuelo->matriculaAvion,"Ingresar Matricula de Avion: ","ERROR",0,20)== -1); do { if(buscarMatricula(aviones,vuelo->matriculaAvion) == -1) { printf("Ingrese matricula valida\n"); while(getString(vuelo->matriculaAvion,"Ingresar Matricula de Avion: ","ERROR",0,20)== -1 ); } else salida=0; } while(salida); strcpy(vuelo->estado,validarEstado()); retorno=0; } } else printf("No se encontro numero de Vuelo\n"); } return retorno; }
const string TimeStamp::getYYYYMMDD_HHMMSS() const { const uint32_t MONTH = getMonth(); const uint32_t DAY = getDay(); const uint32_t HOUR = getHour(); const uint32_t MINUTE = getMinute(); const uint32_t SECOND = getSecond(); stringstream s; s << getYear() << "-" << ( (MONTH < 10) ? "0" : "" ) << MONTH << "-" << ( (DAY < 10) ? "0" : "" ) << DAY << " " << ( (HOUR < 10) ? "0" : "" ) << HOUR << ":" << ( (MINUTE < 10) ? "0" : "" ) << MINUTE << ":" << ( (SECOND < 10) ? "0" : "" ) << SECOND; return s.str(); }
/********************************************************************************************************************** *Description: Function for getting time (hours, minutes and seconds). This function fills a structure called local_time accessible in the class RTCInt. *Input Parameters: None *Return Parameter: None ***********************************************************************************************************************/ void RTCInt::getTime(void) { unsigned int hour=0, h=0; local_time.hour = getHour(); if(time_Mode == TIME_H12) { h=RTC->MODE2.CLOCK.bit.HOUR; while (RTCSync()); local_time.Tmode = h & 0x10; } local_time.minute = getMinute(); local_time.second = getSecond(); }
eVuelo* altaVuelo(ArrayList* aviones,ArrayList* vuelos) { char matricula[20]; int salida=1; eVuelo* vuelo= NULL; while(getString(matricula,"Ingresar Matricula de Avion: ","ERROR",0,20)== -1); if(buscarMatricula(aviones,matricula)!= -1) { vuelo=malloc(sizeof(eVuelo)); if(vuelo != NULL) { strcpy(vuelo->matriculaAvion,matricula); while(getInt(&(vuelo->idVuelo),"Ingresar Numero de Vuelo: ","ERROR",0,9999) == -1 ); do { if(buscarIdVuelo(vuelos,vuelo->idVuelo) == -1)// verifica si encuentra o no el numero de vuelo salida=0;// no lo encontro else { printf("Numero de Vuelo Repetido\n"); while(getInt(&(vuelo->idVuelo),"Ingresar Numero de Vuelo: ","ERROR",0,9999) == -1 ); } } while(salida); while(getString(vuelo->origen,"Ingresar Origen: ","ERROR",0,50) == -1); while(getString(vuelo->destino,"Ingresar Destino: ","ERROR",0,50)== -1); while(getHour(vuelo,"Ingrese Hora de Salida (HH:MM) : ","ERROR",1)== -1); while(getHour(vuelo,"Ingrese Hora de Llegada (HH:MM) : ","ERROR",0)== -1); strcpy(vuelo->estado,validarEstado()); } else printf("No hay espacio para mas vuelos\n"); } else printf("\nMatricula Invalida\n"); return vuelo; }
ossimRefPtr<ossimXmlNode> ossimLocalTm::saveXml()const { ossimRefPtr<ossimXmlNode> result = new ossimXmlNode; result->setTag("ossimDate"); result->addAttribute("version", "1"); result->addChildNode("month", ossimString::toString(getMonth())); result->addChildNode("day", ossimString::toString(getDay())); result->addChildNode("year", ossimString::toString(getYear())); result->addChildNode("hour", ossimString::toString(getHour())); result->addChildNode("minutes", ossimString::toString(getMin())); result->addChildNode("seconds", ossimString::toString(getSec())); result->addChildNode("fractionalSecond", ossimString::toString(getFractionalSecond())); return result.get(); }
/* * Get the timestamp (Unix Epoch) for date, time in * strings, as seen in the log file. */ int getTimestamp(const char *date, const char *time) { int ts; struct tm epoc, current; epoc.tm_hour = 0; epoc.tm_min = 0; epoc.tm_sec = 0; epoc.tm_year = 1970-1900; epoc.tm_mon = 0; epoc.tm_mday = 1; epoc.tm_isdst = -1; // Daylight Saving Time correction: let mktime() guess current.tm_hour = getHour(time); current.tm_min = getMinute(time); current.tm_sec = 0; current.tm_year = getYear(date)-1900; current.tm_mon = getMonth(date)-1; current.tm_mday = getDay(date); current.tm_isdst = -1; ts = difftime(mktime(¤t), mktime(&epoc)); return ts; }
// Get desired temp: // input parameter: // char fileName[] : string representation of file dir and name // return type: // float : return desired temp from config file: float getDesired(char fileName[]) { float desired; int config_hour; int current_hour = getHour(); FILE* configFile = openFile(fileName, "r"); while (fscanf(configFile, "%d %f", &config_hour, &desired) != EOF) { if (config_hour == current_hour) break; } fclose(configFile); return desired; }
void Timestamp::setMonth(int month) { if (month > 12) throw invalid_argument(StringUtil::substitute("month is over 12: {0}", month)); //달력 int year = getYear(); int newDate = getDate(); array<int, 12> &monthArray = getLastDateArray(year); //해당 월의 마지막 일을 초과할 때, 조정한다 //EX-> 4월인데 31일이면 4월 30일로 조정 if (newDate > monthArray[month - 1]) newDate = monthArray[month - 1]; setTimestamp(year, month, newDate, getHour(), getMinute(), getSecond()); };
struct direntry mkFCB(uchar type, char *name, int size, uint *clusNum) { char buf[4] = {0xff,0xff,0xff,0xff}; struct direntry de; strncpy((char*)(de.deName), name, 11); // memset(de.deExtension, 0, sizeof(de.deExtension)); de.deAttributes = type; // 文件创建时间和日期 de.deCTime = combineUchar(getHour(), getMinute()); de.deCDate = combineUchar(getMonth(), getDay()); de.deMTime = de.deCTime; de.deMDate = de.deCDate; de.deFileSize = size; *clusNum = cnallloc(); de.deHighClust = (ushort)((*clusNum) >> 16); de.deLowCluster = (ushort)(*clusNum); wsect4bytes(fatFstSec, *clusNum, buf); return de; }
nint NDateTime::compareTo(const INObject * other) const { if (this == other) return 0; try { const NDateTime * obj = dynamic_cast<const NDateTime *>(other); if (obj != NULL) { int result = 0; if ((result = getYear() - obj->getYear()) == 0) { if ((result = getMonth() - obj->getMonth()) == 0) { if ((result = getDay() - obj->getDay()) == 0) { if ((result = getHour() - obj->getHour()) == 0) { if ((result = getMinute() - obj->getMinute()) == 0) { if ((result = getSecond() - obj->getSecond()) == 0) { result = getMillisecond() - obj->getMillisecond(); } } } } } } return result; } else { return 1; } } catch (bad_cast &) { return 1; } }
int CimTask::svc() { while (!m_stop) { string curdate = getCurDate(); if (getHour() == m_checkHour && m_lastCheckDate != curdate) { // 检测时间到,进行文件比较 if(checkFile()) { // 需要更新CIM,更新数据库字段未待导库 updateIsNew(); } m_lastCheckDate = curdate; } ACE_OS::sleep(5); } return 0; }
//SET METHODS void Timestamp::setYear(int year) { int month = getMonth(); int newDate = getDate(); //윤달에 29일인데 addYear을 하려는 경우 if ( month == 2 && newDate == 29 //현재가 윤달 29일 && !( year == 4 && !((year % 100 == 0 && year % 400 != 0)) ) //바꿀 연도의 2월은 윤달이 아님 ) newDate = 28; setTimestamp(year, month, newDate, getHour(), getMinute(), getSecond()); };
void nebulaEye::recordCSVData(){ if (!record) return; int row = csvRecorder.numRows; int idx = 0; csvRecorder.setString(row, 0, getDate()); csvRecorder.setString(row, 1, getHour()); int area(0), biggest(-1); for (int i = 0; i < contour.finder.size(); i++ ){ if ( contour.finder.getContourArea(i) > area ){ biggest = i; area = contour.finder.getContourArea(i); } } if ( biggest != -1 ){ ofVec2f centroid = ofxCv::toOf(contour.finder.getCentroid(biggest)); centroid /= bgSub.m_fgmask.cols; centroid -= zone.center; ofVec2f centroidPol = nebula::Utils::carToPol(centroid); centroidPol.y -= zone.angleOrigin; centroidPol.y = ofWrapDegrees(centroidPol.y); csvRecorder.setFloat(row,2,centroidPol.x); csvRecorder.setFloat(row,3,centroidPol.y); } else { csvRecorder.setString(row,2,"NA"); csvRecorder.setString(row,3,"NA"); } csvRecorder.setFloat(row,4,flowZone[0]); csvRecorder.setFloat(row,5,flowZone[1]); csvRecorder.setFloat(row,6,flowZone[2]); csvRecorder.setFloat(row,7,flowZone[3]); }
bool isValid(const vector<bool>& vec) { return getHour(vec) < 12 && getMinute(vec) < 60; }
string toTime(const vector<bool>& vec) { int h = getHour(vec), m = getMinute(vec); return to_string(h) + ":" + (m < 10 ? "0" : "") + to_string(m); }