X Tutup
Skip to content

Commit b4d7db6

Browse files
committed
DateTime: Removed Should Be Date/Time.
Update issue 415 Removed Should Be Date/Time keywords. They were inconsistent with other Should keywords because they returned status as True/False and didn't use exceptions on failure. We could have either changed names or functionality, but because we couldn't figure out any good use cases for them, we decided removing was easiest.
1 parent 0bd1d6d commit b4d7db6

File tree

5 files changed

+2
-135
lines changed

5 files changed

+2
-135
lines changed

atest/robot/standard_libraries/datetime/should_be_date.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

atest/robot/standard_libraries/datetime/should_be_time.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

atest/testdata/standard_libraries/datetime/should_be_date.txt

Lines changed: 0 additions & 29 deletions
This file was deleted.

atest/testdata/standard_libraries/datetime/should_be_time.txt

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/robot/libraries/DateTime.py

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -290,62 +290,11 @@
290290
from robot.utils import elapsed_time_to_string, secs_to_timestr, timestr_to_secs
291291

292292
__version__ = get_version()
293-
__all__ = ['should_be_date', 'should_be_time', 'convert_time', 'convert_date',
294-
'subtract_dates', 'subtract_from_date', 'subtract_from_time',
293+
__all__ = ['convert_time', 'convert_date', 'subtract_dates',
294+
'subtract_from_date', 'subtract_from_time',
295295
'add_to_time', 'add_to_date', 'get_current_date']
296296

297297

298-
# TODO: Are Should Be Date/Time needed? Should at least rename them to
299-
# Is Date/Time or change them to raise exception when verification fails.
300-
# If removed, remove also from __all__!!
301-
def should_be_date(date, date_format=None):
302-
"""Validate input to be a date.
303-
304-
`date` is valid when it is in one of the supported `date formats`.
305-
306-
`date_format` can be used to specify a `custom timestamp`.
307-
308-
Returns `True` if `date` is valid and `False` otherwise.
309-
310-
Examples:
311-
| ${result} = | Should Be Date | 2014-06-02 11:59:01.001 |
312-
| Should Be True | ${result} |
313-
| ${result} = | Should Be Date | 11:59:01.001 02-06-2014 | %H:%M:%S %d-%m-%Y |
314-
| Should Be True | ${result} |
315-
| ${result} = | Should Be Date | no date here |
316-
| Should Not Be True | ${result} |
317-
| ${result} = | Should Be Date | ${111} |
318-
| Should Be True | ${result} |
319-
| ${result} = | Should Be Date | 111 |
320-
| Should Not Be True | ${result} |
321-
"""
322-
try:
323-
Date(date, date_format)
324-
except ValueError:
325-
return False
326-
return True
327-
328-
329-
def should_be_time(time):
330-
"""Validate input to be a time value.
331-
332-
`time` is valid when it is in one of the `Time Formats`.
333-
334-
Returns `True` if `time` is valid and `False` otherwise.
335-
336-
Examples:
337-
| ${result} = | Should Be Time | 10 s |
338-
| Should Be True | ${result} |
339-
| ${result} = | Should Be Time | 1 parsec |
340-
| Should Not Be True | ${result} |
341-
"""
342-
try:
343-
Time(time)
344-
except ValueError:
345-
return False
346-
return True
347-
348-
349298
def convert_time(time, result_format='number', exclude_millis=False):
350299
"""Converts between supported `time formats`.
351300

0 commit comments

Comments
 (0)
X Tutup