当前位置: 首页>>代码示例>>C++>>正文


C++ MINUTES函数代码示例

本文整理汇总了C++中MINUTES函数的典型用法代码示例。如果您正苦于以下问题:C++ MINUTES函数的具体用法?C++ MINUTES怎么用?C++ MINUTES使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MINUTES函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: nmea_gprmc

/** Assemble an NMEA GPRMC message and send it out NMEA USARTs.
 * NMEA RMC contains minimum GPS data 
 *
 * \param nav_meas Pointer to navigation_measurement struct.
 * \param soln Pointer to gnss_solution struct
 * \param gps_t Pointer to the current GPS Time
 */
void nmea_gprmc(const navigation_measurement_t *nav_meas,
                const gnss_solution *soln, const gps_time_t *gps_t)
{
  
  /* NMEA Parameters
   * Ex.
   * $GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*70
   *   |      |    |    |    |    |     |   |      |      |     |  |  |
   * Command  |    |   Lat  N/S   |     |   |      | Date Stamp | W/E |
   *    Time (UTC) |            Long   W/E  |  True Course      |   Cksum
   *            Validity (A-OK)           Speed            Variation 
   * Variation is ignored as we have no way to maintain that information
   * currently
   */
  time_t unix_t;
  struct tm t;

  unix_t = gps2time(*gps_t);
  gmtime_r(&unix_t, &t);
  double frac_s = fmod(gps_t->tow, 1.0);

  s16 lat_deg = R2D * (soln->pos_llh[0]);
  double lat_min = MINUTES(soln->pos_llh[0]);
  s16 lon_deg = R2D * (soln->pos_llh[1]);
  double lon_min = MINUTES(soln->pos_llh[1]);
  lat_deg = abs(lat_deg);
  lon_deg = abs(lon_deg);

  char lat_dir = soln->pos_llh[0] < 0 ? 'S' : 'N';
  char lon_dir = soln->pos_llh[1] < 0 ? 'W' : 'E';

  float velocity;
  float x,y,z;
  x = soln->vel_ned[0];
  y = soln->vel_ned[1];
  z = soln->vel_ned[2];
  float course = atan2(y,x);

  /* Conversion to magnitue knots */
  velocity = MS2KNOTTS(x,y,z);

  double az, el;
  wgsecef2azel(nav_meas[0].sat_pos, soln->pos_ecef, &az, &el);

  char buf[100];
  u8 n = sprintf(buf,
                "$GPRMC,%02d%02d%06.3f,A," /* Command, Time (UTC), Valid */
                "%02d%010.7f,%c,%03d%010.7f,%c," /* Lat/Lon */
                "%06.2f,%05.1f," /* Speed, Course */
                "%02d%02d%02d," /* Date Stamp */
                ",", /* Variation */
                t.tm_hour, t.tm_min, t.tm_sec + frac_s,
                lat_deg, lat_min, lat_dir, lon_deg, lon_min, lon_dir,
                velocity, course * R2D, 
                t.tm_mday, t.tm_mon, t.tm_year-100);

  u8 sum = nmea_checksum(buf);
  sprintf(buf + n, "*%02X\r\n", sum);
  nmea_output(buf);
}
开发者ID:imh,项目名称:piksi_firmware,代码行数:67,代码来源:nmea.c

示例2: starttourn

void 
starttourn(void)
{
    int     i, j;
    struct planet *pl;
    char    s[80];

    opentlog();
    for (i = 0, pl = &planets[i]; i < NUMPLANETS; i++, pl++) {
	for (j = 0; j < MAXTEAM + 1; j++) {
	    pl->pl_tinfo[j].timestamp = 0;
	    /* doesn't work? */
	    pl->pl_hinfo = (PL_TYPE(*pl) == PLSTAR) ? ALLTEAM : pl->pl_owner;
	}
    }
    status->clock = 0;

    explode_everyone(KTOURNSTART, 0);

    tlog_all();


    status2->league++;
    status2->leagueticksleft = MINUTES(configvals->regulation_minutes);

    /* version team names configured time date */
    pmessage(" ", 0, MALL, UMPIRE);
    sprintf(s, "Timer started -- %d minutes remaining",
	    status2->leagueticksleft / MINUTES(1));
    pmessage(s, 0, MALL, UMPIRE);
    pmessage(" ", 0, MALL, UMPIRE);
}
开发者ID:ComputerScienceHouse,项目名称:paradise-netrek,代码行数:32,代码来源:tourny.c

示例3: timestr

void
timestr(
	struct timeval	*tv,
	char		*ts,
	size_t		size,
	int		format)
{
	double		usec = (double)tv->tv_usec / 1000000.0;

	if (format & TERSE_FIXED_TIME) {
		if (!HOURS(tv->tv_sec)) {
			snprintf(ts, size, "%u:%02u.%02u",
				(unsigned int) MINUTES(tv->tv_sec),
				(unsigned int) SECONDS(tv->tv_sec),
				(unsigned int) (usec * 100));
			return;
		}
		format |= VERBOSE_FIXED_TIME;	/* fallback if hours needed */
	}

	if ((format & VERBOSE_FIXED_TIME) || tv->tv_sec) {
		snprintf(ts, size, "%u:%02u:%02u.%02u",
			(unsigned int) HOURS(tv->tv_sec),
			(unsigned int) MINUTES(tv->tv_sec),
			(unsigned int) SECONDS(tv->tv_sec),
			(unsigned int) (usec * 100));
	} else {
		snprintf(ts, size, "0.%04u sec", (unsigned int) (usec * 10000));
	}
}
开发者ID:0bliv10n,项目名称:s2e,代码行数:30,代码来源:cmd.c

示例4: batch_time

int recipe::print_time( WINDOW *w, int ypos, int xpos, int width,
                        nc_color col, int batch ) const
{
    const int turns = batch_time( batch ) / 100;
    std::string text;
    if( turns < MINUTES( 1 ) ) {
        const int seconds = std::max( 1, turns * 6 );
        text = string_format( ngettext( "%d second", "%d seconds", seconds ), seconds );
    } else {
        const int minutes = ( turns % HOURS( 1 ) ) / MINUTES( 1 );
        const int hours = turns / HOURS( 1 );
        if( hours == 0 ) {
            text = string_format( ngettext( "%d minute", "%d minutes", minutes ), minutes );
        } else if( minutes == 0 ) {
            text = string_format( ngettext( "%d hour", "%d hours", hours ), hours );
        } else {
            const std::string h = string_format( ngettext( "%d hour", "%d hours", hours ), hours );
            const std::string m = string_format( ngettext( "%d minute", "%d minutes", minutes ), minutes );
            //~ A time duration: first is hours, second is minutes, e.g. "4 hours" "6 minutes"
            text = string_format( _( "%1$s and %2$s" ), h.c_str(), m.c_str() );
        }
    }
    text = string_format( _( "Time to complete: %s" ), text.c_str() );
    return fold_and_print( w, ypos, xpos, width, col, text );
}
开发者ID:Mecares,项目名称:Cataclysm-DDA,代码行数:25,代码来源:crafting_gui.cpp

示例5: to_string

std::string to_string( const time_duration &d )
{
    const int turns = to_turns<int>( d );
    int divider = 0;

    if( turns > MINUTES( 1 ) && turns < calendar::INDEFINITELY_LONG ) {
        if( turns < HOURS( 1 ) ) {
            divider = MINUTES( 1 );
        } else if( turns < DAYS( 1 ) ) {
            divider = HOURS( 1 );
        } else {
            divider = DAYS( 1 );
        }
    }

    const int remainder = divider ? turns % divider : 0;
    if( remainder != 0 ) {
        //~ %1$s - greater units of time (e.g. 3 hours), %2$s - lesser units of time (e.g. 11 minutes).
        return string_format( _( "%1$s and %2$s" ),
                              to_string_clipped( time_duration::from_turns( turns ) ),
                              to_string_clipped( time_duration::from_turns( remainder ) ) );
    }

    return to_string_clipped( d );
}
开发者ID:alapazam,项目名称:Cataclysm-DDA,代码行数:25,代码来源:calendar.cpp

示例6: sum_conditions

////// Funnels.
weather_sum sum_conditions( const calendar &startturn,
                            const calendar &endturn,
                            const tripoint &location )
{
    int tick_size = MINUTES(1);
    weather_sum data;

    for( calendar turn(startturn); turn < endturn; turn += tick_size ) {
        const int diff = endturn - startturn;
        if( diff <= 0 ) {
            return data;
        } else if( diff < 10 ) {
            tick_size = 1;
        } else if( diff > DAYS(7) ) {
            tick_size = HOURS(1);
        } else {
            tick_size = MINUTES(1);
        }

        const auto wtype = g->weather_gen->get_weather_conditions( point( location.x, location.y ), turn );
        proc_weather_sum( wtype, data, turn, tick_size );
    }

    return data;
}
开发者ID:Bubbadoo,项目名称:Cataclysm-DDA,代码行数:26,代码来源:weather.cpp

示例7: rng

mon_id MonsterGroupManager::GetMonsterFromGroup( std::string group, std::vector <mtype*> *mtypes,
                                                 int *quantity, int turn )
{
    int roll = rng(1, 1000);
    MonsterGroup g = monsterGroupMap[group];
    for (FreqDef_iter it = g.monsters.begin(); it != g.monsters.end(); ++it)
    {
        if((turn == -1 || (turn + 900 >= MINUTES(STARTING_MINUTES) + HOURS((*mtypes)[it->first]->difficulty))) &&
           (!OPTIONS["CLASSIC_ZOMBIES"] ||
            (*mtypes)[it->first]->in_category(MC_CLASSIC) ||
            (*mtypes)[it->first]->in_category(MC_WILDLIFE)))
        {   //Not too hard for us (or we dont care)
            if(it->second.first >= roll)
            {
                if( quantity) { *quantity -= it->second.second; }
                return it->first;
            }
            else { roll -= it->second.first; }
        }
    }
    if ((turn + 900 < MINUTES(STARTING_MINUTES) + HOURS((*mtypes)[g.defaultMonster]->difficulty))
        && (!OPTIONS["STATIC_SPAWN"]))
    {
        return mon_null;
    }
    else
    {
        return g.defaultMonster;
    }
}
开发者ID:wigtitit,项目名称:Cataclysm-DDA,代码行数:30,代码来源:mongroupdef.cpp

示例8: nmea_gpgga

/** Assemble a NMEA GPGGA message and send it out NMEA USARTs.
 * NMEA GPGGA message contains Global Positioning System Fix Data.
 *
 * \param soln Pointer to gnss_solution struct.
 * \param dops Pointer to dops_t struct.
 */
void nmea_gpgga(const double pos_llh[3], const gps_time_t *gps_t, u8 n_used,
                u8 fix_type, double hdop)
{
  time_t unix_t;
  struct tm t;

  unix_t = gps2time(*gps_t);
  gmtime_r(&unix_t, &t);

  double frac_s = fmod(gps_t->tow, 1.0);

  s16 lat_deg = R2D * (pos_llh[0]);
  double lat_min = MINUTES(pos_llh[0]);
  s16 lon_deg = R2D * (pos_llh[1]);
  double lon_min = MINUTES(pos_llh[1]);
  lat_deg = abs(lat_deg);
  lon_deg = abs(lon_deg);

  char lat_dir = pos_llh[0] < 0 ? 'S' : 'N';
  char lon_dir = pos_llh[1] < 0 ? 'W' : 'E';

  NMEA_SENTENCE_START(120);
  NMEA_SENTENCE_PRINTF("$GPGGA,%02d%02d%06.3f,"
                       "%02d%010.7f,%c,%03d%010.7f,%c,"
                       "%01d,%02d,%.1f,%.2f,M,,M,,",
                       t.tm_hour, t.tm_min, t.tm_sec + frac_s,
                       lat_deg, lat_min, lat_dir, lon_deg, lon_min, lon_dir,
                       fix_type, n_used, hdop, pos_llh[2]
                       );
  NMEA_SENTENCE_DONE();
}
开发者ID:kovach,项目名称:piksi_firmware,代码行数:37,代码来源:nmea.c

示例9: string_format

std::string calendar::print_duration( int turns )
{
    std::string res;

    if( turns < MINUTES( 1 ) ) {
        int sec = std::max( 1, turns * 6 );
        res += string_format( ngettext( "%d second", "%d seconds", sec ), sec );

    } else if( turns < HOURS( 1 ) ) {
        int min = turns / MINUTES( 1 );
        int sec = turns % MINUTES( 1 );
        res += string_format( ngettext( "%d minute", "%d minutes", min ), min );
        if( sec ) {
            res += string_format( ngettext( " and %d second", " and %d seconds", sec ), sec );
        }

    } else if( turns < DAYS( 1 ) ) {
        int hour = turns / HOURS( 1 );
        int min = turns % HOURS( 1 );
        res += string_format( ngettext( "%d hour", "%d hours", hour ), hour );
        if( min ) {
            res += string_format( ngettext( " and %d minute", " and %d minutes", min ), min );
        }

    } else {
        int day = turns / DAYS( 1 );
        int hour = turns % DAYS( 1 );
        res += string_format( ngettext( "%d day", "%d days", day ), day );
        if( hour ) {
            res += string_format( ngettext( " and %d hour", " and %d hours", hour ), hour );
        }
    }
    return res;
}
开发者ID:RadaRadaRada,项目名称:Cataclysm-DDA,代码行数:34,代码来源:calendar.cpp

示例10: nmea_gpgll

/** Assemble an NMEA GPGLL message and send it out NMEA USARTs.
 * NMEA GLL contains course and speed
 *
 * \param soln Pointer to gnss_solution struct
 * \param gpt_t Pointer to the current GPS Time
 */
void nmea_gpgll(const gnss_solution *soln, const gps_time_t *gps_t)
{
  /* NMEA Parameters for GPGLL
   * Ex.
   * $GPGLL,5133.81,N,00042.25,W,225444,A*75
   *   |       |    |    |     |    |   |
   * Command   |   N/S Lon    E/W   | Valid
   *          LAT                  UTC
   */ 
  time_t unix_t;
  struct tm t;

  unix_t = gps2time(*gps_t);
  gmtime_r(&unix_t, &t);

  double frac_s = fmod(gps_t->tow, 1.0);
  s16 lat_deg = R2D * (soln->pos_llh[0]);
  double lat_min = MINUTES(soln->pos_llh[0]);
  s16 lon_deg = R2D * (soln->pos_llh[1]);
  double lon_min =  MINUTES(soln->pos_llh[1]);
  lat_deg = abs(lat_deg);
  lon_deg = abs(lon_deg);

  char lat_dir = soln->pos_llh[0] < 0 ? 'S' : 'N';
  char lon_dir = soln->pos_llh[1] < 0 ? 'W' : 'E';

  NMEA_SENTENCE_START(120);
  NMEA_SENTENCE_PRINTF("$GPGLL,"
                "%02d%010.7f,%c,%03d%010.7f,%c," /* Lat/Lon */
                "%02d%02d%06.3f,A", /* Time (UTC), Valid */
                lat_deg, lat_min, lat_dir, lon_deg, lon_min, lon_dir,
                t.tm_hour, t.tm_min, t.tm_sec + frac_s);
  NMEA_SENTENCE_DONE();
}
开发者ID:kovach,项目名称:piksi_firmware,代码行数:40,代码来源:nmea.c

示例11: nmea_gprmc

/** Assemble an NMEA GPRMC message and send it out NMEA USARTs.
 * NMEA RMC contains minimum GPS data 
 *
 * \param soln Pointer to gnss_solution struct
 * \param gps_t Pointer to the current GPS Time
 */
void nmea_gprmc(const gnss_solution *soln, const gps_time_t *gps_t)
{
  
  /* NMEA Parameters
   * Ex.
   * $GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*70
   *   |      |    |    |    |    |     |   |      |      |     |  |  |
   * Command  |    |   Lat  N/S   |     |   |      | Date Stamp | W/E |
   *    Time (UTC) |            Long   W/E  |  True Course      |   Cksum
   *            Validity (A-OK)           Speed            Variation 
   * Variation is ignored as we have no way to maintain that information
   * currently
   */
  time_t unix_t;
  struct tm t;

  unix_t = gps2time(*gps_t);
  gmtime_r(&unix_t, &t);
  double frac_s = fmod(gps_t->tow, 1.0);

  s16 lat_deg = R2D * (soln->pos_llh[0]);
  double lat_min = MINUTES(soln->pos_llh[0]);
  s16 lon_deg = R2D * (soln->pos_llh[1]);
  double lon_min = MINUTES(soln->pos_llh[1]);
  lat_deg = abs(lat_deg);
  lon_deg = abs(lon_deg);

  char lat_dir = soln->pos_llh[0] < 0 ? 'S' : 'N';
  char lon_dir = soln->pos_llh[1] < 0 ? 'W' : 'E';

  float velocity;
  float x,y,z;
  x = soln->vel_ned[0];
  y = soln->vel_ned[1];
  z = soln->vel_ned[2];
  float course = atan2(y,x);

  /* Conversion to magnitue knots */
  velocity = MS2KNOTTS(x,y,z);

  NMEA_SENTENCE_START(140);
  NMEA_SENTENCE_PRINTF(
                "$GPRMC,%02d%02d%06.3f,A," /* Command, Time (UTC), Valid */
                "%02d%010.7f,%c,%03d%010.7f,%c," /* Lat/Lon */
                "%06.2f,%05.1f," /* Speed, Course */
                "%02d%02d%02d," /* Date Stamp */
                ",", /* Variation */
                t.tm_hour, t.tm_min, t.tm_sec + frac_s,
                lat_deg, lat_min, lat_dir, lon_deg, lon_min, lon_dir,
                velocity, course * R2D, 
                t.tm_mday, t.tm_mon + 1, t.tm_year % 100);
  NMEA_SENTENCE_DONE();
}
开发者ID:EmuxEvans,项目名称:piksi_firmware,代码行数:59,代码来源:nmea.c

示例12: string_format

std::string calendar::print_approx_duration( int turns, bool verbose )
{
    const auto make_result = [verbose]( int turns, const char *verbose_str, const char *short_str ) {
        return string_format( verbose ? verbose_str : short_str, print_clipped_duration( turns ).c_str() );
    };

    int divider = 0;
    int vicinity = 0;

    if( turns > DAYS( 1 ) ) {
        divider = DAYS( 1 );
        vicinity = HOURS( 2 );
    } else if( turns > HOURS( 1 ) ) {
        divider = HOURS( 1 );
        vicinity = MINUTES( 5 );
    } // Minutes and seconds can be estimated precisely.

    if( divider != 0 ) {
        const int remainder = turns % divider;

        if( remainder >= divider - vicinity ) {
            turns += divider;
        } else if( remainder > vicinity ) {
            if( remainder < divider / 2 ) {
                //~ %s - time (e.g. 2 hours).
                return make_result( turns, _( "more than %s" ), ">%s" );
            } else {
                //~ %s - time (e.g. 2 hours).
                return make_result( turns + divider, _( "less than %s" ), "<%s" );
            }
        }
    }
    //~ %s - time (e.g. 2 hours).
    return make_result( turns, _( "about %s" ), "%s" );
}
开发者ID:CoderDuan,项目名称:Cataclysm-DDA,代码行数:35,代码来源:calendar.cpp

示例13: add_msg

void activity_handlers::vibe_do_turn( player_activity *act, player *p )
{
    //Using a vibrator takes time, not speed
    act->moves_left -= 100;

    item &vibrator_item = p->i_at(act->position);

    if( (p->is_wearing("rebreather")) || (p->is_wearing("rebreather_xl")) ||
        (p->is_wearing("mask_h20survivor")) ) {
        act->moves_left = 0;
        add_msg(m_bad, _("You have trouble breathing, and stop."));
    }

    //Deduct 1 battery charge for every minute using the vibrator
    if( calendar::once_every(MINUTES(1)) ) {
        vibrator_item.charges--;
        p->add_morale(MORALE_FEELING_GOOD, 4, 320); //4 points/min, one hour to fill
        // 1:1 fatigue:morale ratio, so maxing the morale is possible but will take
        // you pretty close to Dead Tired from a well-rested state.
        p->fatigue += 4;
    }
    if( vibrator_item.charges == 0 ) {
        act->moves_left = 0;
        add_msg(m_info, _("The %s runs out of batteries."), vibrator_item.tname().c_str());
    }
    if( p->fatigue >= DEAD_TIRED ) { // Dead Tired: different kind of relaxation needed
        act->moves_left = 0;
        add_msg(m_info, _("You're too tired to continue."));
    }

    // Vibrator requires that you be able to move around, stretch, etc, so doesn't play
    // well with roots.  Sorry.  :-(

    p->pause();
}
开发者ID:jvj24601,项目名称:Cataclysm-DDA,代码行数:35,代码来源:activity_handlers.cpp

示例14: year_turns

void calendar::sync()
{
    year = turn_number / year_turns();
    season = season_type(turn_number / DAYS(season_length()) % 4);
    day = turn_number / DAYS(1) % season_length();
    hour = turn_number / HOURS(1) % 24;
    minute = turn_number / MINUTES(1) % 60;
    second = (turn_number * 6) % 60;
}
开发者ID:Atzerkins,项目名称:Cataclysm-DDA,代码行数:9,代码来源:calendar.cpp

示例15: season_length

void calendar::sync()
{
    const int sl = season_length();
    year = turn_number / DAYS(sl * 4);
    season = season_type(turn_number / DAYS(sl) % 4);
    day = turn_number / DAYS(1) % sl;
    hour = turn_number / HOURS(1) % 24;
    minute = turn_number / MINUTES(1) % 60;
    second = (turn_number * 6) % 60;
}
开发者ID:0x90sled,项目名称:Cataclysm-DDA,代码行数:10,代码来源:calendar.cpp


注:本文中的MINUTES函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。