difftimeFmt: Formats a time difference in multiple units

Description Usage Arguments Value Author(s) Examples

View source: R/difftimeFmt.r

Description

This function converts a time difference (in seconds) into a string with various time units (days, hours, minutes, seconds and milliseconds).

Usage

1

Arguments

x

Time difference to format (single value). Can be a floating number of seconds, or a difftime object.

Value

Returns a character of length 1, according to the following format : "[d]d [h]:[m]:[s].[ms]". Days and milliseconds are omitted if they can be.

Author(s)

Sylvain Mareschal

Examples

1
2
3
4
5
6
7
8
  # Full format
  difftimeFmt(94521.125846)
  
  # With dates
  T1 <- strptime("2011-03-21 14:32:03", format="%Y-%m-%d %H:%M:%S")
  T2 <- strptime("2011-08-06 18:14:21", format="%Y-%m-%d %H:%M:%S")
  dT <- as.double(difftime(T2, T1, units="secs"))
  difftimeFmt(dT)

ODB documentation built on March 26, 2020, 7:46 p.m.