diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/utils/convert.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/python/vyos/utils/convert.py b/python/vyos/utils/convert.py index bdc9fd549..f867b4167 100644 --- a/python/vyos/utils/convert.py +++ b/python/vyos/utils/convert.py @@ -26,10 +26,14 @@ time_units = { def human_to_seconds(time_str): - """ Converts a human-readable interval such as 1w4d18h35m59s - to number of seconds + """Converts a human-readable interval such as 1w4d18h35m59s + to number of seconds. A plain number is taken as seconds. """ + time_str = str(time_str) + if time_str.isdigit(): + return int(time_str) + time_patterns = { 'y': r'(\d+)\s*y', 'w': r'(\d+)\s*w', |
