def subtract_date_from_date(date1, date2, result_format='number', exclude_millis=False, date1_format=None, date2_format=None): """Subtracts date from another date and returns time between. Arguments: - ``date1:`` Date to subtract another date from in one of the supported `date formats`. - ``date2:`` Date that is subtracted in one of the supported `date formats`. - ``result_format:`` Format of the returned time (see `time formats`). - ``exclude_millis:`` When set to any true value, rounds and drops milliseconds as explained in `millisecond handling`. - ``date1_format:`` Possible `custom timestamp` format of ``date1``. - ``date2_format:`` Possible `custom timestamp` format of ``date2``. Examples: | ${time} = | Subtract Date From Date | 2014-05-28 12:05:52 | 2014-05-28 12:05:10 | | Should Be Equal | ${time} | ${42} | | ${time} = | Subtract Date From Date | 2014-05-28 12:05:52 | 2014-05-27 12:05:10 | verbose | | Should Be Equal | ${time} | 1 day 42 seconds | """ time = Date(date1, date1_format) - Date(date2, date2_format) return time.convert(result_format, millis=is_falsy(exclude_millis))
def add_time_to_time(time1, time2, result_format="number", exclude_millis=False): """Adds time to another time and returns the resulting time. Arguments: - ``time1:`` First time in one of the supported `time formats`. - ``time2:`` Second time in one of the supported `time formats`. - ``result_format:`` Format of the returned time. - ``exclude_millis:`` When set to any true value, rounds and drops milliseconds as explained in `millisecond handling`. Examples: | ${time} = | Add Time To Time | 1 minute | 42 | | Should Be Equal | ${time} | ${102} | | ${time} = | Add Time To Time | 3 hours 5 minutes | 01:02:03 | timer | exclude_millis=yes | | Should Be Equal | ${time} | 04:07:03 | """ time = Time(time1) + Time(time2) return time.convert(result_format, millis=is_falsy(exclude_millis))
def add_time_to_time(time1, time2, result_format='number', exclude_millis=False): """Adds time to another time and returns the resulting time. Arguments: - _time1:_ First time in one of the supported `time formats`. - _time2:_ Second time in one of the supported `time formats`. - _result_format:_ Format of the returned time. - _exclude_millis:_ When set to any true value, rounds and drops milliseconds as explained in `millisecond handling`. Examples: | ${time} = | Add Time To Time | 1 minute | 42 | | Should Be Equal | ${time} | ${102} | | ${time} = | Add Time To Time | 3 hours 5 minutes | 01:02:03 | timer | exclude_millis=yes | | Should Be Equal | ${time} | 04:07:03 | """ time = Time(time1) + Time(time2) return time.convert(result_format, millis=not exclude_millis)
def subtract_time_from_time(time1, time2, result_format="number", exclude_millis=False): """Subtracts time from another time and returns the resulting time. Arguments: - ``time1:`` Time to subtract another time from in one of the supported `time formats`. - ``time2:`` Time to subtract in one of the supported `time formats`. - ``result_format:`` Format of the returned time. - ``exclude_millis:`` When set to any true value, rounds and drops milliseconds as explained in `millisecond handling`. Examples: | ${time} = | Subtract Time From Time | 00:02:30 | 100 | | Should Be Equal | ${time} | ${50} | | ${time} = | Subtract Time From Time | ${time} | 1 minute | compact | | Should Be Equal | ${time} | - 10s | """ time = Time(time1) - Time(time2) return time.convert(result_format, millis=is_falsy(exclude_millis))
def subtract_time_from_time(time1, time2, result_format='number', exclude_millis=False): """Subtracts time from another time and returns the resulting time. Arguments: - _time1:_ Time to subtract another time from in one of the supported `time formats`. - _time2:_ Time to subtract in one of the supported `time formats`. - _result_format:_ Format of the returned time. - _exclude_millis:_ When set to any true value, rounds and drops milliseconds as explained in `millisecond handling`. Examples: | ${time} = | Subtract Time From Time | 00:02:30 | 100 | | Should Be Equal | ${time} | ${50} | | ${time} = | Subtract Time From Time | ${time} | 1 minute | compact | | Should Be Equal | ${time} | - 10s | """ time = Time(time1) - Time(time2) return time.convert(result_format, millis=not exclude_millis)
def subtract_date_from_date(date1, date2, result_format='number', exclude_millis=False, date1_format=None, date2_format=None): """Subtracts date from another date and returns time between. Arguments: - _date1:_ Date to subtract another date from in one of the supported `date formats`. - _date2:_ Date that is subtracted in one of the supported `date formats`. - _result_format:_ Format of the returned time (see `time formats`). - _exclude_millis:_ When set to any true value, rounds and drops milliseconds as explained in `millisecond handling`. - _date1_format:_ Specifies possible `custom timestamp` format of _date1_. - _date2_format:_ Specifies possible `custom timestamp` format of _date2_. Examples: | ${time} = | Subtract Date From Date | 2014-05-28 12:05:52 | 2014-05-28 12:05:10 | | Should Be Equal | ${time} | ${42} | | ${time} = | Subtract Date From Date | 2014-05-28 12:05:52 | 2014-05-27 12:05:10 | verbose | | Should Be Equal | ${time} | 1 day 42 seconds | """ time = Date(date1, date1_format) - Date(date2, date2_format) return time.convert(result_format, millis=not exclude_millis)