timestring              package:runjags              R Documentation

_C_a_l_c_u_l_a_t_e _t_h_e _E_l_a_p_s_e_d _T_i_m_e _i_n _S_e_n_s_i_b_l_e _U_n_i_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     Function to calculate the elapsed time between 2 time periods (in
     seconds), or to calculate a number of seconds into a time
     measurement in more sensible units.

_U_s_a_g_e:

     timestring(time1, time2=NA, units=NA, show.units=TRUE)

_A_r_g_u_m_e_n_t_s:

   time1: either the time index (from Sys.time()) at the start of the
          time period, or a length of time in seconds.

   time2: either the time index (from Sys.time()) at the end of the
          time period, or missing data if converting a single length of
          time.  Default NA.

   units: either missing, in which case a sensible time unit is chosen
          automatically, or one of 's', 'm', 'h', 'd', 'w', 'y' to
          force a specific unit.  Default NA.

show.units: if TRUE, then the time is returned with units, if FALSE
          then just an integer is returned.  Default TRUE.

_V_a_l_u_e:

     A time measurement, with or without units.

_A_u_t_h_o_r(_s):

     Matthew Denwood m.denwood@vet.gla.ac.uk funded as part of the
     DEFRA VTRI project 0101.

_S_e_e _A_l_s_o:

     'Sys.time'

_E_x_a_m_p_l_e_s:

     # time how long it takes to complete a task:

     pre.time <- Sys.time()
     for (i in 1:10000000) hold <- exp(100)  # PROCESS TO TIME
     post.time <- Sys.time()
     timestring(pre.time, post.time)

     # Convert 4687 seconds into hours:

     timestring(4687, units='hours', show.units=FALSE)

