Robot Framework Integrated Development Environment (RIDE)
robotide.lib.robot.utils.robottime Namespace Reference

Classes

class  _SecsToTimestrHelper
 
class  TimestampCache
 

Functions

def _elapsed_time_to_string (elapsed)
 
def _elapsed_time_to_string_without_millis (elapsed)
 
def _float_secs_to_secs_and_millis (secs)
 
def _get_timetuple (epoch_secs=None)
 
def _normalize_timestamp (ts, seps)
 
def _normalize_timestr (timestr)
 
def _number_to_secs (number)
 
def _parse_time_epoch (timestr)
 
def _parse_time_now_and_utc (timestr)
 
def _parse_time_now_and_utc_base (base)
 
def _parse_time_now_and_utc_extra (extra)
 
def _parse_time_timestamp (timestr)
 
def _split_timestamp (timestamp)
 
def _time_string_to_secs (timestr)
 
def _timer_to_secs (number)
 
def _timestamp_to_millis (timestamp, seps=None)
 
def elapsed_time_to_string (elapsed, include_millis=True)
 Converts elapsed time in milliseconds to format 'hh:mm:ss.mil'. More...
 
def format_time (timetuple_or_epochsecs, daysep='', daytimesep=' ', timesep=':', millissep=None)
 Returns a timestamp formatted from given time using separators. More...
 
def get_elapsed_time (start_time, end_time)
 Returns the time between given timestamps in milliseconds. More...
 
def get_time (format='timestamp', time_=None)
 Return the given or current time in requested format. More...
 
def get_timestamp (daysep='', daytimesep=' ', timesep=':', millissep='.')
 
def parse_time (timestr)
 Parses the time string and returns its value as seconds since epoch. More...
 
def secs_to_timestamp (secs, seps=None, millis=False)
 
def secs_to_timestr (secs, compact=False)
 Converts time in seconds to a string representation. More...
 
def timestamp_to_secs (timestamp, seps=None)
 
def timestr_to_secs (timestr, round_to=3)
 Parses time like '1h 10s', '01:00:10' or '42' and returns seconds. More...
 

Variables

 _timer_re
 
 TIMESTAMP_CACHE = TimestampCache()
 

Function Documentation

◆ _elapsed_time_to_string()

def robotide.lib.robot.utils.robottime._elapsed_time_to_string (   elapsed)
private

Definition at line 344 of file robottime.py.

◆ _elapsed_time_to_string_without_millis()

def robotide.lib.robot.utils.robottime._elapsed_time_to_string_without_millis (   elapsed)
private

Definition at line 350 of file robottime.py.

◆ _float_secs_to_secs_and_millis()

def robotide.lib.robot.utils.robottime._float_secs_to_secs_and_millis (   secs)
private

Definition at line 38 of file robottime.py.

◆ _get_timetuple()

def robotide.lib.robot.utils.robottime._get_timetuple (   epoch_secs = None)
private

Definition at line 31 of file robottime.py.

◆ _normalize_timestamp()

def robotide.lib.robot.utils.robottime._normalize_timestamp (   ts,
  seps 
)
private

Definition at line 364 of file robottime.py.

◆ _normalize_timestr()

def robotide.lib.robot.utils.robottime._normalize_timestr (   timestr)
private

Definition at line 98 of file robottime.py.

◆ _number_to_secs()

def robotide.lib.robot.utils.robottime._number_to_secs (   number)
private

Definition at line 53 of file robottime.py.

◆ _parse_time_epoch()

def robotide.lib.robot.utils.robottime._parse_time_epoch (   timestr)
private

Definition at line 255 of file robottime.py.

◆ _parse_time_now_and_utc()

def robotide.lib.robot.utils.robottime._parse_time_now_and_utc (   timestr)
private

Definition at line 270 of file robottime.py.

◆ _parse_time_now_and_utc_base()

def robotide.lib.robot.utils.robottime._parse_time_now_and_utc_base (   base)
private

Definition at line 279 of file robottime.py.

◆ _parse_time_now_and_utc_extra()

def robotide.lib.robot.utils.robottime._parse_time_now_and_utc_extra (   extra)
private

Definition at line 288 of file robottime.py.

◆ _parse_time_timestamp()

def robotide.lib.robot.utils.robottime._parse_time_timestamp (   timestr)
private

Definition at line 264 of file robottime.py.

◆ _split_timestamp()

def robotide.lib.robot.utils.robottime._split_timestamp (   timestamp)
private

Definition at line 372 of file robottime.py.

◆ _time_string_to_secs()

def robotide.lib.robot.utils.robottime._time_string_to_secs (   timestr)
private

Definition at line 73 of file robottime.py.

◆ _timer_to_secs()

def robotide.lib.robot.utils.robottime._timer_to_secs (   number)
private

Definition at line 59 of file robottime.py.

◆ _timestamp_to_millis()

def robotide.lib.robot.utils.robottime._timestamp_to_millis (   timestamp,
  seps = None 
)
private

Definition at line 357 of file robottime.py.

◆ elapsed_time_to_string()

def robotide.lib.robot.utils.robottime.elapsed_time_to_string (   elapsed,
  include_millis = True 
)

Converts elapsed time in milliseconds to format 'hh:mm:ss.mil'.

If `include_millis` is True, '.mil' part is omitted.

Definition at line 335 of file robottime.py.

◆ format_time()

def robotide.lib.robot.utils.robottime.format_time (   timetuple_or_epochsecs,
  daysep = '',
  daytimesep = ' ',
  timesep = ':',
  millissep = None 
)

Returns a timestamp formatted from given time using separators.

Time can be given either as a timetuple or seconds after epoch.

Timetuple is (year, month, day, hour, min, sec[, millis]), where parts must
be integers and millis is required only when millissep is not None.
Notice that this is not 100% compatible with standard Python timetuples
which do not have millis.

Seconds after epoch can be either an integer or a float.

Definition at line 182 of file robottime.py.

◆ get_elapsed_time()

def robotide.lib.robot.utils.robottime.get_elapsed_time (   start_time,
  end_time 
)

Returns the time between given timestamps in milliseconds.

Definition at line 320 of file robottime.py.

◆ get_time()

def robotide.lib.robot.utils.robottime.get_time (   format = 'timestamp',
  time_ = None 
)

Return the given or current time in requested format.

If time is not given, current time is used. How time is returned is
is deternined based on the given 'format' string as follows. Note that all
checks are case insensitive.

- If 'format' contains word 'epoch' the time is returned in seconds after
  the unix epoch.
- If 'format' contains any of the words 'year', 'month', 'day', 'hour',
  'min' or 'sec' only selected parts are returned. The order of the returned
  parts is always the one in previous sentence and order of words in
  'format' is not significant. Parts are returned as zero padded strings
  (e.g. May -> '05').
- Otherwise (and by default) the time is returned as a timestamp string in
  format '2006-02-24 15:08:31'

Definition at line 211 of file robottime.py.

◆ get_timestamp()

def robotide.lib.robot.utils.robottime.get_timestamp (   daysep = '',
  daytimesep = ' ',
  timesep = ':',
  millissep = '.' 
)

Definition at line 296 of file robottime.py.

◆ parse_time()

def robotide.lib.robot.utils.robottime.parse_time (   timestr)

Parses the time string and returns its value as seconds since epoch.

Time can be given in five different formats:

1) Numbers are interpreted as time since epoch directly. It is possible to
   use also ints and floats, not only strings containing numbers.
2) Valid timestamp ('YYYY-MM-DD hh:mm:ss' and 'YYYYMMDD hhmmss').
3) 'NOW' (case-insensitive) is the current local time.
4) 'UTC' (case-insensitive) is the current time in UTC.
5) Format 'NOW - 1 day' or 'UTC + 1 hour 30 min' is the current local/UTC
   time plus/minus the time specified with the time string.

Seconds are rounded down to avoid getting times in the future.

Definition at line 246 of file robottime.py.

◆ secs_to_timestamp()

def robotide.lib.robot.utils.robottime.secs_to_timestamp (   secs,
  seps = None,
  millis = False 
)

Definition at line 309 of file robottime.py.

◆ secs_to_timestr()

def robotide.lib.robot.utils.robottime.secs_to_timestr (   secs,
  compact = False 
)

Converts time in seconds to a string representation.

Returned string is in format like
'1 day 2 hours 3 minutes 4 seconds 5 milliseconds' with following rules:

- Time parts having zero value are not included (e.g. '3 minutes 4 seconds'
  instead of '0 days 0 hours 3 minutes 4 seconds')
- Hour part has a maximun of 23 and minutes and seconds both have 59
  (e.g. '1 minute 40 seconds' instead of '100 seconds')

If compact has value 'True', short suffixes are used.
(e.g. 1d 2h 3min 4s 5ms)

Definition at line 126 of file robottime.py.

◆ timestamp_to_secs()

def robotide.lib.robot.utils.robottime.timestamp_to_secs (   timestamp,
  seps = None 
)

Definition at line 300 of file robottime.py.

◆ timestr_to_secs()

def robotide.lib.robot.utils.robottime.timestr_to_secs (   timestr,
  round_to = 3 
)

Parses time like '1h 10s', '01:00:10' or '42' and returns seconds.

Definition at line 45 of file robottime.py.

Variable Documentation

◆ _timer_re

robotide.lib.robot.utils.robottime._timer_re
private

Definition at line 28 of file robottime.py.

◆ TIMESTAMP_CACHE

robotide.lib.robot.utils.robottime.TIMESTAMP_CACHE = TimestampCache()

Definition at line 419 of file robottime.py.