void o2fsck_print_resource_track(char *pass, o2fsck_state *ost, struct o2fsck_resource_track *rt, io_channel *channel) { struct ocfs2_io_stats *rtio = &rt->rt_io_stats; uint64_t total_io, cache_read; float rtime_s, utime_s, stime_s, walltime; uint32_t rtime_m, utime_m, stime_m; if (!ost->ost_show_stats) return ; if (pass && !ost->ost_show_extended_stats) return; #define split_time(_t, _m, _s) \ do { \ (_s) = timeval_in_secs(&_t); \ (_m) = (_s) / 60; \ (_s) -= ((_m) * 60); \ } while (0); split_time(rt->rt_real_time, rtime_m, rtime_s); split_time(rt->rt_user_time, utime_m, utime_s); split_time(rt->rt_sys_time, stime_m, stime_s); walltime = timeval_in_secs(&rt->rt_real_time) - timeval_in_secs(&rt->rt_user_time); /* TODO: Investigate why user time is sometimes > wall time*/ if (walltime < 0) walltime = 0; cache_read = (uint64_t)rtio->is_cache_hits * io_get_blksize(channel); total_io = rtio->is_bytes_read + rtio->is_bytes_written; if (!pass) printf(" Cache size: %luMB\n", mbytes(io_get_cache_size(channel))); printf(" I/O read disk/cache: %"PRIu64"MB / %"PRIu64"MB, " "write: %"PRIu64"MB, rate: %.2fMB/s\n", mbytes(rtio->is_bytes_read), mbytes(cache_read), mbytes(rtio->is_bytes_written), (double)(mbytes(total_io) / walltime)); printf(" Times real: %dm%.3fs, user: %dm%.3fs, sys: %dm%.3fs\n", rtime_m, rtime_s, utime_m, utime_s, stime_m, stime_s); }
//------------------------------------------------------------------------- // // Returns the year component of a DateTime. // int DateTime::getYear( ) const //------------------------------------------------------------------------- { tm tim; split_time( mTicks, &tim ); return tim.tm_year; }
//------------------------------------------------------------------------- // // Returns the month component of a DateTime. // int DateTime::getMonth( ) const //------------------------------------------------------------------------- { tm tim; split_time( mTicks, &tim ); return tim.tm_mon; }
/** * Fill the items in the receipt dialog with values. */ void MainScreen::fillReceiptDialog(MAUtil::String appID, MAUtil::String productID, int transactionDate, MAUtil::String transactionId, MAUtil::String versionExternalId, MAUtil::String BID) { // If the field is unavailable, print a line character instead. if ( appID.length() == 0 ) appID = "-"; if ( productID.length() == 0 ) productID = "-"; if ( transactionDate == 0 ) mReceiptTransactionDate->setText("-"); else { tm transaction; split_time(transactionDate, &transaction); mReceiptTransactionDate->setText( MAUtil::integerToString(transaction.tm_mday) + "." + MAUtil::integerToString(transaction.tm_mon +1) + "." + MAUtil::integerToString(transaction.tm_year +1900) + " / " + MAUtil::integerToString(transaction.tm_hour +1) + ":" + MAUtil::integerToString(transaction.tm_min +1) + ":" + MAUtil::integerToString(transaction.tm_sec +1) ); } mReceiptProductId->setText(productID); mReceiptAppId->setText(appID); if ( getPlatform() == IOS ) { mReceiptTransactionId->setText(transactionId); mReceiptVersionExternalId->setText(versionExternalId); mReceiptBid->setText(BID); } mReceiptDialog->show(); }
//------------------------------------------------------------------------- // // Returns the hour component of a DateTime. // int DateTime::getHour( ) const //------------------------------------------------------------------------- { tm tim; split_time( mTicks, &tim ); return tim.tm_hour; }
//------------------------------------------------------------------------- // // Returns the minute component of a DateTime. // int DateTime::getMinute( ) const //------------------------------------------------------------------------- { tm tim; split_time( mTicks, &tim ); return tim.tm_min; }
//------------------------------------------------------------------------- // // Returns the second component of a DateTime. // int DateTime::getSecond( ) const //------------------------------------------------------------------------- { tm tim; split_time( mTicks, &tim ); return tim.tm_sec; }
static void parse_time_string(int *hour, int *minute, const char *time) { char *hours; char *minutes; hours = (char *)malloc(3); minutes = (char *)malloc(3); memset(hours, 0, 3); memset(minutes, 0, 3); if (split_time((char **)&hours, (char **)&minutes, time) == 1) { *hour = 0; *minute = 0; if ((parse_number((char *)hours, 0, 23, hour) != -1) && (parse_number((char *)minutes, 0, 59, minute) != -1)) { free(hours); free(minutes); return; } } free(hours); free(minutes); /* If we are here, there was a problem ..*/ exit_error(PARAMETER_PROBLEM, "invalid time `%s' specified, should be HH:MM format", time); }
static void parse_time_string(unsigned int *hour, unsigned int *minute, const char *time) { char *hours; char *minutes; hours = (char *)malloc(3); minutes = (char *)malloc(3); bzero((void *)hours, 3); bzero((void *)minutes, 3); if (split_time(&hours, &minutes, time) == 1) { /* if the number starts with 0, replace it with a space else this string_to_number will interpret it as octal !! */ if ((hours[0] == '0') && (hours[1] != '\0')) hours[0] = ' '; if ((minutes[0] == '0') && (minutes[1] != '\0')) minutes[0] = ' '; if((string_to_number(hours, 0, 23, hour) == -1) || (string_to_number(minutes, 0, 59, minute) == -1)) { *hour = *minute = (-1); } } if ((*hour != (-1)) && (*minute != (-1))) { free(hours); free(minutes); return; } /* If we are here, there was a problem ..*/ print_error("invalid time %s specified, should be HH:MM format", time); }
//------------------------------------------------------------------------- // // Returns the day component of a DateTime. // int DateTime::getDay( ) const //------------------------------------------------------------------------- { tm tim; split_time( mTicks, &tim ); return tim.tm_mday; }
/** * Get the date and time when the system will deliver the notification. * @return A date and time struct that specifies when the system will * deliver the notification. */ struct tm LocalNotification::getFireDate() const { int minDateMilliseconds = this->getPropertyInt(MA_NOTIFICATION_LOCAL_FIRE_DATE); tm timeStruct; split_time(minDateMilliseconds, &timeStruct); return timeStruct; }
int main(void) { int total_sec = 7403, hours, minutes, seconds; split_time(total_sec, &hours, &minutes, &seconds); printf("hour: %d, minute: %d, second: %d\n", hours, minutes, seconds); return 0; }
//------------------------------------------------------------------------- // // Adds specified number of seconds to current value and returns as a new DateTime. // DateTime DateTime::addYears( int years ) const //------------------------------------------------------------------------- { tm tim; split_time( mTicks, &tim ); tim.tm_year += years; return DateTime( mktime( &tim ) ); }
void main() { long int total_sec; printf("enter total time in seconds \n"); scanf("%ld",&total_sec); int hr,min,sec; split_time(total_sec,&hr,&min,&sec); }
void print_info(const options_t& opt, double elapsed, uint64_t blocks, uint64_t orbits, uint64_t points, double error) { int eh, em, es, ed, rh, rm, rs, rd; bool valid_eta = false; double remaining = std::numeric_limits<double>::infinity(); if(opt.use_max && blocks != 0) { valid_eta = true; double progress = (double)blocks / opt.max_blocks; remaining = (1.0 - progress) / progress * elapsed; } if(opt.use_orb && orbits != 0) { valid_eta = true; double progress = (double)orbits / opt.max_orbits; remaining = std::min(remaining, (1.0 - progress) / progress * elapsed); } if(opt.use_err && blocks >= 2 && error != 0.0 && !std::isnan(error)) { valid_eta = true; double d = std::log(error)/std::log(blocks); size_t max_block = std::pow(opt.error, 1.0/d); double progress = (double)blocks / max_block; remaining = std::min(remaining, (1.0 - progress) / progress * elapsed); } split_time(elapsed, eh, em, es, ed); split_time(remaining, rh, rm, rs, rd); printf("runtime: %02d:%02d:%02d.%02d, ", eh, em, es, ed); if(!valid_eta || remaining < 0.0) printf("ETA: N/A, "); else printf("ETA: %02d:%02d:%02d.%02d, ", rh, rm, rs, rd); if(opt.use_max) { printf("blocks: %lu/%lu, orbits: %lu, points: %lu, error: %f\n", blocks, opt.max_blocks, orbits, points, error); } else { printf("blocks: %lu, orbits: %lu, points: %lu, error: %f\n", blocks, orbits, points, error); } fflush(stdout); }
int main() { long int total_sec; int hr, min, sec; printf("Enter your time in seconds : "); scanf("%ld",&total_sec); hr=min=sec=0; split_time(total_sec, &hr, &min, &sec); printf("%d:%d:%d\n",hr,min,sec); return 0; }
int main(void) { struct time result; long total_seconds; printf("Enter the total seconds: "); scanf("%ld", &total_seconds); result = split_time(total_seconds); printf("%.2d:%.2d:%.2d\n", result.hours, result.minutes, result.seconds); return 0; }
//------------------------------------------------------------------------- // // returns today's date in local time, as a DateTime. // DateTime DateTime::today( ) //------------------------------------------------------------------------- { time_t now = maLocalTime( ); tm tim; split_time( now, &tim ); tim.tm_hour = 0; tim.tm_min = 0; tim.tm_sec = 0; return DateTime( mktime( &tim ) ); }
char* write_time(double time, char* out) { int yyyy,mm,dd,hh,mi,ss,msec; /* Get constituent parts of date and time. */ if (split_time(time,&yyyy,&mm,&dd,&hh,&mi,&ss,&msec)) return ""; /* Create and return the ISF string*/ sprintf(out,"%02d-%02d-%d %02d:%02d:%02d.%03d",dd,mm,yyyy,hh,mi,ss,msec); return out; }
//------------------------------------------------------------------------- // // Adds specified number of monts to current value and returns as a new DateTime. // DateTime DateTime::addMonths( int months ) const //------------------------------------------------------------------------- { tm tim; split_time( mTicks, &tim ); tim.tm_mon += months; while ( tim.tm_mon >= 12 ) { tim.tm_mon -= 12; tim.tm_year++; } return DateTime( mktime( &tim ) ); }
int main(void) { long total_sec; int hr = 0, min = 0, sec = 0; printf("Enter a time as number of seconds since midnight: "); scanf("%ld", &total_sec); split_time(total_sec, &hr, &min, &sec); printf("Time given was %.2d:%.2d:%.2d\n", hr, min, sec); printf("Check: %d * 3600 + %d * 60 + %d = %ld\n", hr, min, sec, (long) hr * 3600 + min * 60 + sec); return 0; }
int main(int argc, char **argv) { // Check command line arguments if (argc != 2) { fprintf(stderr, "Usage: ./split-time n\n"); return EXIT_FAILURE; } // Declare variables long total_sec = atol(argv[1]); int hour, min, sec; split_time(total_sec, &hour, &min, &sec); printf("split_time = %.2d:%.2d:%.2d\n", hour, min, sec); return EXIT_SUCCESS; }
std::string ColumnInPreview(const FullPreview& full, const std::string& name, bool thin) { if (name == "player") { return full.preview.main_player_name; } else if (name == "empire") { return full.preview.main_player_empire_name; } else if (name == "turn") { return boost::lexical_cast<std::string>(full.preview.current_turn); } else if (name == "time") { if (thin) { return split_time(full.preview.save_time); } else { return full.preview.save_time; } } else if (name == "file") { return full.filename; } else if (name == "galaxy_size") { return boost::lexical_cast<std::string>(full.galaxy.m_size); } else if (name == "seed") { return full.galaxy.m_seed; } else if (name == "galaxy_age") { return TextForGalaxySetupSetting(full.galaxy.m_age); } else if (name == "monster_freq") { return TextForGalaxySetupSetting(full.galaxy.m_monster_freq); } else if (name == "native_freq") { return TextForGalaxySetupSetting(full.galaxy.m_native_freq); } else if (name == "planet_freq") { return TextForGalaxySetupSetting(full.galaxy.m_planet_density); } else if (name == "specials_freq") { return TextForGalaxySetupSetting(full.galaxy.m_specials_freq); } else if (name == "starlane_freq") { return TextForGalaxySetupSetting(full.galaxy.m_starlane_freq); } else if (name == "galaxy_shape") { return TextForGalaxyShape(full.galaxy.m_shape); } else if (name == "ai_aggression") { return TextForAIAggression(full.galaxy.m_ai_aggr); } else if (name == "number_of_empires") { return boost::lexical_cast<std::string>(full.preview.number_of_empires); } else if (name == "number_of_humans") { return boost::lexical_cast<std::string>(full.preview.number_of_human_players); } else { ErrorLogger() << "FullPreview::Value Error: no such preview field: " << name; return "??"; } }
LPCSTR GAME_NEWS_DATA::SingleLineText() { if( xr_strlen(full_news_text.c_str()) ) return full_news_text.c_str(); string128 time = ""; // Calc current time u32 years, months, days, hours, minutes, seconds, milliseconds; split_time (receive_time, years, months, days, hours, minutes, seconds, milliseconds); #pragma todo("Satan->Satan : insert carry-over") //sprintf(time, "%02i:%02i \\n", hours, minutes); sprintf (time, "%02i:%02i ", hours, minutes); // strconcat (result, locationName, time, newsPhrase); full_news_text = time; full_news_text += news_text.c_str(); return full_news_text.c_str(); }
/// Creates a row for the given savefile SaveFileRow ( const std::string& filename, const SaveGamePreviewData& preview ) : m_type ( PREVIEW ) { SetMargin ( ROW_MARGIN ); this->m_filename = filename; CalculateColumnWidths(); boost::shared_ptr<GG::Font> font = ClientUI::GetFont(); GG::Clr item_clr = ClientUI::TextColor(); std::string save_time = split_time ( preview.save_time ); push_back ( new GG::TextControl ( GG::X0, GG::Y0, m_time_column_width, font->Height(), save_time, font, item_clr, GG::FORMAT_LEFT ) ); push_back ( new GG::TextControl ( GG::X0, GG::Y0, m_turn_column_width, font->Height(), std::string ( " " ) + boost::lexical_cast<std::string> ( preview.current_turn ), font, item_clr, GG::FORMAT_LEFT ) ); push_back ( CreateResizingText(preview.main_player_name, font, item_clr) ); push_back ( CreateResizingText(preview.main_player_empire_name, font, preview.main_player_empire_colour) ); push_back ( CreateResizingText(filename, font, item_clr) ); }
String AuctionListScreen::getTime(String enddate) { String all = enddate; String year = ""; String month = ""; String day = ""; struct tm * cmp_p = new tm; int indexof = all.find("-"); if (indexof > -1) { year = all.substr(0,indexof++).c_str(); all=all.substr(indexof); } indexof = all.find("-"); if (indexof > -1) { month = all.substr(0,indexof++).c_str(); all=all.substr(indexof); day = all; } cmp_p->tm_hour = 23; cmp_p->tm_min = 59; cmp_p->tm_sec = 59; cmp_p->tm_year = Convert::toInt(year)-1900; cmp_p->tm_mon = Convert::toInt(month)-1; cmp_p->tm_mday = Convert::toInt(day); time_t test = mktime(cmp_p); time_t timeleft = test - maTime(); if (timeleft < 0) { //should be set to zero, for now gonna use negative inferred value for testing timeleft = 0; //expired = true; } split_time(timeleft, cmp_p); char buffer[128]; memset(buffer, 0, 128); String days = "Days"; String hours = "Hours"; if (cmp_p->tm_mday == 1) { days = "Days"; } if (cmp_p->tm_hour == 1) { hours = "Hours"; } if (cmp_p->tm_mday == 1) { snprintf(buffer, 128, "%d %s %d %s", cmp_p->tm_mday, days.c_str(), cmp_p->tm_hour, hours.c_str()); } else { snprintf(buffer, 128, "%d %s %d %s", cmp_p->tm_mday, days.c_str(), cmp_p->tm_hour, hours.c_str()); } delete cmp_p; cmp_p = NULL; if (timeleft == 0) { return "Expired"; } return buffer; }
void CLevel::GetGameDateTime (u32& year, u32& month, u32& day, u32& hours, u32& mins, u32& secs, u32& milisecs) { split_time(GetGameTime(), year, month, day, hours, mins, secs, milisecs); }
/** * This method is called if the touch-up event was inside the * bounds of the button. * @param button The button object that generated the event. */ void CreateNotificationScreen::buttonClicked(Widget* button) { printf("CreateNotificationScreen::buttonClicked"); if (button == mCreateNotificationButton) { if (!this->isUserInputDataValid()) { return; } LocalNotification* notification = new LocalNotification(); mLocalNotificationVector.add(notification); // Set fire date. String secondsString = mTime->getText(); int seconds = MAUtil::stringToInteger(secondsString); int secondsLocalTime = maLocalTime(); int scheduleTime = secondsLocalTime + seconds; tm fireDate; split_time(scheduleTime, &fireDate); notification->setFireDate(&fireDate); // Set content body MAUtil::String contentBody = mContentBody->getText(); notification->setContentBody(contentBody); // Set play sound property bool playSound = mPlaySound->isChecked(); notification->setPlaySound(playSound); if (isIOS()) { // Set badge number MAUtil::String badgeNumberString = mBadgeNumber->getText(); int badgeNumber = MAUtil::stringToInteger(badgeNumberString, 10); notification->setBadgeNumber(badgeNumber); // Set alert action. MAUtil::String alertAction = mAlertAction->getText(); notification->setAlertAction(alertAction); } else { notification->setContentTitle(mContentTitle->getText()); notification->setTickerText(mTickerText->getText()); if ( mVibrate->isChecked() ) { notification->setVibrate(true); if ( mVibrateDuration->getText().length() > 0 ) { notification->setVibrateDuration( MAUtil::stringToInteger(mVibrateDuration->getText())); } } else { notification->setVibrate(false); } if ( mFlash->isChecked() ) { // Check if flashing LED is possible on the device. // if ( MA_NOTIFICATION_RES_OK == notification->setFlashLights(true) ) if ( notification->setFlashLights(true) ) { mFlashColor->setText("IS available"); if ( checkFlashPattern() ) { struct NotificationFlashLights pattern = NotificationFlashLights( MAUtil::stringToInteger(mFlashColor->getText()), MAUtil::stringToInteger(mFlashOnLength->getText()), MAUtil::stringToInteger(mFlashOffLength->getText())); notification->setFlashLightsPattern(pattern); } } else { mFlashColor->setText("Not available"); mFlashOffLength->setText("Not available"); mFlashOnLength->setText("Not available"); mFlashColor->setEnabled(false); mFlashOffLength->setEnabled(false); mFlashOnLength->setEnabled(false); mFlash->setState(false); mFlash->setEnabled(false); } } else { notification->setFlashLights(false); } if ( playSound ) { notification->setSound(mSoundPath->getText()); } } // notification->setFlag(NOTIFICATION_FLAG_AUTO_CANCEL); NotificationManager::getInstance()->scheduleLocalNotification(notification); printf("notification created with handle = %d ", notification->getHandle()); this->resetView(); } }
void xrTime::get (u32 &y, u32 &mo, u32 &d, u32 &h, u32 &mi, u32 &s, u32 &ms) { split_time(m_time,y,mo,d,h,mi,s,ms); }
virtual void Status (TStatus& S) { u32 year = 1, month = 1, day = 1, hours = 0, mins = 0, secs = 0, milisecs = 0; split_time (g_qwStartGameTime, year, month, day, hours, mins, secs, milisecs); sprintf_s (S,"%d.%d.%d %d:%d:%d.%d",year,month,day,hours,mins,secs,milisecs); }