3 new revisions:

Revision: e1de3ab2ce0f
Branch:   default
Author:   Pekka Klärck
Date:     Wed Jun  4 21:54:59 2014 UTC
Log:      time format: compatibility with previous releases...
http://code.google.com/p/robotframework/source/detail?r=e1de3ab2ce0f

Revision: ddea13b48914
Branch:   default
Author:   Pekka Klärck
Date:     Wed Jun  4 22:02:12 2014 UTC
Log:      Time format: Support also + prefix with timer strings...
http://code.google.com/p/robotframework/source/detail?r=ddea13b48914

Revision: 5667658e2b6b
Branch:   default
Author:   Pekka Klärck
Date:     Thu Jun  5 08:56:18 2014 UTC
Log:      DateTime: Let enhanced timestr_to_secs handle timer conversion....
http://code.google.com/p/robotframework/source/detail?r=5667658e2b6b

==============================================================================
Revision: e1de3ab2ce0f
Branch:   default
Author:   Pekka Klärck
Date:     Wed Jun  4 21:54:59 2014 UTC
Log:      time format: compatibility with previous releases

Update issue 1715
Other tests revealed that earlier time format supported also
'millisec(s)' and 'msec(s)'. That was probably an accident caused by
how the time format was parsed, but better to keep supporting them
anyway. Also enhanced related tests otherwise.
http://code.google.com/p/robotframework/source/detail?r=e1de3ab2ce0f

Modified:
 /src/robot/utils/robottime.py
 /utest/utils/test_robottime.py

=======================================
--- /src/robot/utils/robottime.py       Wed Jun  4 17:48:13 2014 UTC
+++ /src/robot/utils/robottime.py       Wed Jun  4 21:54:59 2014 UTC
@@ -95,12 +95,14 @@

 def _normalize_timestr(timestr):
     timestr = normalize(timestr)
- for specifier, aliases in [('x', ('milliseconds', 'millisecond', 'millis', 'ms')),
-                               ('s', ('seconds', 'second', 'secs', 'sec')),
-                               ('m', ('minutes', 'minute', 'mins', 'min')),
-                               ('h', ('hours', 'hour')),
-                               ('d', ('days', 'day'))]:
-        for alias in aliases:
+    for specifier, aliases in [('x', ['millisecond', 'millisec', 'millis',
+                                      'msec', 'ms']),
+                               ('s', ['second', 'sec']),
+                               ('m', ['minute', 'min']),
+                               ('h', ['hour']),
+                               ('d', ['day'])]:
+        plural_aliases = [a+'s' for a in aliases if not a.endswith('s')]
+        for alias in plural_aliases + aliases:
             if alias in timestr:
                 timestr = timestr.replace(alias, specifier)
     return timestr
=======================================
--- /utest/utils/test_robottime.py      Wed Jun  4 17:48:13 2014 UTC
+++ /utest/utils/test_robottime.py      Wed Jun  4 21:54:59 2014 UTC
@@ -60,18 +60,33 @@
                          ('10DAY10H10M10SEC', 900610),
                          ('1day 23h 46min 7s 666ms', 171967.666),
                          ('1.5min 1.5s', 91.5),
+                         ('1.5 days', 60*60*36),
                          ('1 day', 60*60*24),
+                         ('2 days', 2*60*60*24),
                          ('1 d', 60*60*24),
                          ('1 hour', 60*60),
+                         ('3 hours', 3*60*60),
                          ('1 h', 60*60),
                          ('1 minute', 60),
+                         ('2 minutes', 2*60),
+                         ('1 min', 60),
+                         ('2 mins', 2*60),
                          ('1 m', 60),
                          ('1 second', 1),
+                         ('2 seconds', 2),
+                         ('1 sec', 1),
+                         ('2 secs', 2),
                          ('1 s', 1),
                          ('1 millisecond', 0.001),
+                         ('2 milliseconds', 0.002),
+                         ('1 millisec', 0.001),
+                         ('2 millisecs', 0.002),
+                         ('1234 millis', 1.234),
+                         ('1 msec', 0.001),
+                         ('2 msecs', 0.002),
                          ('1 ms', 0.001),
                          ('-1s', -1),
-                         ('-1 min 2 s', -62),
+                         ('- 1 min 2 s', -62),
                          ('0.1millis', 0),
                          ('0.5ms', 0.001),
                          ('0day 0hour 0minute 0seconds 0millisecond', 0)]:

==============================================================================
Revision: ddea13b48914
Branch:   default
Author:   Pekka Klärck
Date:     Wed Jun  4 22:02:12 2014 UTC
Log:      Time format: Support also + prefix with timer strings

Update issue 1715
DateTime supported also + prefix with timer strings. Now timestr_to_secs supports it too.
http://code.google.com/p/robotframework/source/detail?r=ddea13b48914

Modified:
 /src/robot/utils/robottime.py
 /utest/utils/test_robottime.py

=======================================
--- /src/robot/utils/robottime.py       Wed Jun  4 21:54:59 2014 UTC
+++ /src/robot/utils/robottime.py       Wed Jun  4 22:02:12 2014 UTC
@@ -20,7 +20,7 @@
 from .misc import plural_or_not


-_timer_re = re.compile('(-)?(\d+:)?(\d+):(\d+)(.\d+)?')
+_timer_re = re.compile('([+-])?(\d+:)?(\d+):(\d+)(.\d+)?')


 def _get_timetuple(epoch_secs=None):
@@ -58,13 +58,13 @@
     match = _timer_re.match(number)
     if not match:
         return None
-    negative, hours, minutes, seconds, millis = match.groups()
+    prefix, hours, minutes, seconds, millis = match.groups()
     seconds = float(minutes) * 60 + float(seconds)
     if hours:
         seconds += float(hours[:-1]) * 60 * 60
     if millis:
         seconds += float(millis[1:]) / 10**len(millis[1:])
-    if negative:
+    if prefix == '-':
         seconds *= -1
     return seconds

=======================================
--- /utest/utils/test_robottime.py      Wed Jun  4 21:54:59 2014 UTC
+++ /utest/utils/test_robottime.py      Wed Jun  4 22:02:12 2014 UTC
@@ -110,6 +110,9 @@
                          ('-00:00:00', 0),
                          ('-00:01:10', -70),
                          ('-1:2:3', -3600 - 2*60 - 3),
+                         ('+00:00:00', 0),
+                         ('+00:01:10', 70),
+                         ('+1:2:3', 3600 + 2*60 + 3),
                          ('00:00:00.0', 0),
                          ('00:00:00.000', 0),
                          ('00:00:00.000000000', 0),

==============================================================================
Revision: 5667658e2b6b
Branch:   default
Author:   Pekka Klärck
Date:     Thu Jun  5 08:56:18 2014 UTC
Log:      DateTime: Let enhanced timestr_to_secs handle timer conversion.

Update issue 415
Refactoring:
- timestr_to_secs nowadays handles parsing timer format (issue 1715)
- added tests for timer format features
- changed terminology to use 'timer' instead of 'clock' format
http://code.google.com/p/robotframework/source/detail?r=5667658e2b6b

Modified:
 /atest/robot/standard_libraries/datetime/convert_time_input_format.txt
 /atest/robot/standard_libraries/datetime/convert_time_result_format.txt
 /atest/testdata/standard_libraries/datetime/convert_time_input_format.txt
 /atest/testdata/standard_libraries/datetime/convert_time_result_format.txt
 /atest/testdata/standard_libraries/datetime/subtract_dates.txt
 /atest/testdata/standard_libraries/datetime/time_calculations.txt
 /src/robot/libraries/DateTime.py

=======================================
--- /atest/robot/standard_libraries/datetime/convert_time_input_format.txt Fri Apr 25 13:22:40 2014 UTC +++ /atest/robot/standard_libraries/datetime/convert_time_input_format.txt Thu Jun 5 08:56:18 2014 UTC
@@ -13,10 +13,13 @@
 Number
     Check Test Case    ${TESTNAME}

-Clock
+Timer
+    Check Test Case    ${TESTNAME}
+
+Timer without millis
     Check Test Case    ${TESTNAME}

-Clock without millis
+Timer without hours
     Check Test Case    ${TESTNAME}

 Timedelta
=======================================
--- /atest/robot/standard_libraries/datetime/convert_time_result_format.txt Fri Apr 25 13:22:40 2014 UTC +++ /atest/robot/standard_libraries/datetime/convert_time_result_format.txt Thu Jun 5 08:56:18 2014 UTC
@@ -13,7 +13,7 @@
 Convert to compact string
     Check Test Case    ${TESTNAME}

-Convert to clock
+Convert to timer
     Check Test Case    ${TESTNAME}

 Convert to timedelta
=======================================
--- /atest/testdata/standard_libraries/datetime/convert_time_input_format.txt Mon May 26 12:20:29 2014 UTC +++ /atest/testdata/standard_libraries/datetime/convert_time_input_format.txt Thu Jun 5 08:56:18 2014 UTC
@@ -24,9 +24,10 @@
                       ${-0.5}                               -0.5
                       ${0}                                  0

-Clock                 00:00:00.000                          0
+Timer                 00:00:00.000                          0
                       00:00:00.001                          0.001
                       00:00:01.000                          1
+                      00:00:01.5                            1.5
                       01:02:03.004                          3723.004
                       99:59:59.999                          359999.999
                       100:00:00.000                         360000
@@ -36,14 +37,28 @@
                       1:00:00.000                           3600
                       000000000:00:00.001                   0.001
                       000000001:00:00.000                   3600
+                      000000001:00:00.5000000               3600.5
+                      000000001:00:00.5                     3600.5
+                      1:2:3                                 3723

-Clock without millis
+Timer without millis
                       00:00:00                              0
                       00:00:01                              1
                       01:02:03                              3723
                       99:59:59                              359999
                       100:00:00                             360000

+Timer without hours
+                      00:00                                 0
+                      01:02                                 62
+                      0:0                                   0
+                      1:2                                   62
+                      00:00.123                             0.123
+                      000:000.000                           0
+                      007:007.007                           427.007
+                      0:0.0                                 0
+                      1:2.3                                 62.3
+
 Timedelta             ${timedelta(1)}                       86400
                       ${timedelta(seconds=1.5)}             1.5
                       ${timedelta(hours=-1)}                -3600
=======================================
--- /atest/testdata/standard_libraries/datetime/convert_time_result_format.txt Fri Apr 25 13:22:40 2014 UTC +++ /atest/testdata/standard_libraries/datetime/convert_time_result_format.txt Thu Jun 5 08:56:18 2014 UTC
@@ -17,9 +17,9 @@
                       ${-62.3}           COMPACT      - 1min 2s 300ms
                       ${timedelta(2)}    COMpact      2d

-Convert to clock      10 s               clock        00:00:10.000
-                      ${-62.3}           CLOCK        -00:01:02.300
-                      ${timedelta(5)}    CLock        120:00:00.000
+Convert to timer      10 s               timer        00:00:10.000
+                      ${-62.3}           TIMER        -00:01:02.300
+                      ${timedelta(5)}    TImeR        120:00:00.000

 Convert to timedelta
10 s timedelta ${timedelta(seconds=10)}
@@ -30,7 +30,7 @@
                       61.5               number       ${62}
                       61.5               verbose      1 minute 2 seconds
                       61.5               compact      1min 2s
-                      61.5               clock        00:01:02
+                      61.5               timer        00:01:02
61.5 timedelta ${timedelta(seconds=62)}

Invalid format [Documentation] FAIL ValueError: Unknown format 'invalid'.
=======================================
--- /atest/testdata/standard_libraries/datetime/subtract_dates.txt Mon May 26 12:20:29 2014 UTC +++ /atest/testdata/standard_libraries/datetime/subtract_dates.txt Thu Jun 5 08:56:18 2014 UTC
@@ -13,11 +13,11 @@
     ${DATE2}                   ${DATE1}               1 hour
     ${DATE1}                   ${DATE2}               - 1 hour
${DATE2} ${DATE1} ${3600.0} result_format=number - ${DATE2} ${DATE1} 01:00:00.000 result_format=clock + ${DATE2} ${DATE1} 01:00:00.000 result_format=timer ${DATE2} ${DATE1} 1h result_format=compact ${DATE2} ${DATE1} ${timedelta(hours=1)} result_format=timedelta
     2014.04.24 22:45:12.123    ${DATE1}               1 hour
- 22:45:12 2014.04.24 2014-04-24 21.43.11 01:02:01.000 result_format=clock date1_format=%H:%M:%S %Y.%m.%d date2_format=%Y-%m-%d %H.%M.%S + 22:45:12 2014.04.24 2014-04-24 21.43.11 01:02:01.000 result_format=timer date1_format=%H:%M:%S %Y.%m.%d date2_format=%Y-%m-%d %H.%M.%S

 *** Keywords ***
 Subtraction Should Succeed
=======================================
--- /atest/testdata/standard_libraries/datetime/time_calculations.txt Mon May 26 12:20:29 2014 UTC +++ /atest/testdata/standard_libraries/datetime/time_calculations.txt Thu Jun 5 08:56:18 2014 UTC
@@ -6,14 +6,14 @@
 Time addition to time should succeed
     [Template]    Time Addition To Time Should Succeed
     01:00:00.000         1 hour      2 hours
-    5 hours 3 minutes    4 minutes   05:07:00.000    clock
-    5 hours 3 minutes    ${4.0}      05:03:04.000    clock
+    5 hours 3 minutes    4 minutes   05:07:00.000    timer
+    5 hours 3 minutes    ${4.0}      05:03:04.000    timer

 Time subtraction from time should succeed
     [Template]    Time Subtraction From Time Should Succeed
     02:00:00.000    1 hour    1 hour
-    5 hours 3 minutes    4 minutes   04:59:00.000    clock
-    5 hours 3 minutes    ${4.0}      05:02:56.000    clock
+    5 hours 3 minutes    4 minutes   04:59:00.000    timer
+    5 hours 3 minutes    ${4.0}      05:02:56.000    timer

 *** Keywords ***
 Time Addition To Time Should Succeed
=======================================
--- /src/robot/libraries/DateTime.py    Mon Jun  2 13:09:38 2014 UTC
+++ /src/robot/libraries/DateTime.py    Thu Jun  5 08:56:18 2014 UTC
@@ -53,7 +53,7 @@
     | number          | 3903.0                  |
     | verbose         | 1hour 5minutes 3seconds |
     | compact         | 1h 5m 3s                |
-    | clock           | 01:05:03.000            |
+    | timer           | 01:05:03.000            |
     | timedelta       | Python timedelta object |

     = Date formats =
@@ -289,7 +289,7 @@
         Examples:
         | ${time} =       | Add To Time | 01:00:00.000      | 3h |
         | Should Be Equal | ${time}     | ${14400}          |
- | ${time} = | Add To Time | 3 hours 5 minutes | 00:01:00.000 | clock | + | ${time} = | Add To Time | 3 hours 5 minutes | 00:01:00.000 | timer |
         | Should Be Equal | ${time}     | 03:06:00.000      |

         New in Robot Framework 2.8.5.
@@ -357,8 +357,8 @@
             return datetime.utcnow()
         raise ValueError('Unsupported timezone %s' % time_zone)

+
 class Time(object):
-    _clock_re = re.compile('([-+])?(\d+):(\d{2}):(\d{2})(\.\d{3})?')

     def __init__(self, time):
         self.seconds = self._convert_time_to_seconds(time)
@@ -378,21 +378,8 @@
             # timedelta.total_seconds() is new in Python 2.7
             return (time.days * 24 * 60 * 60 + time.seconds +
                     time.microseconds / 1000000.0)
-        if isinstance(time, basestring):
-            match = self._clock_re.match(time)
-            if match:
-                return self._convert_clock_to_secs(match)
         return timestr_to_secs(time)

-    def _convert_clock_to_secs(self, match):
-        prefix, hours, minutes, seconds, millis = match.groups()
-        result = 60 * 60 * int(hours) + 60 * int(minutes) + int(seconds)
-        if millis:
-            result += int(millis[1:]) / 1000.0
-        if prefix == '-':
-            result *= -1
-        return result
-
     def convert(self, format, millis=True):
         try:
result_converter = getattr(self, '_convert_to_%s' % format.lower())
@@ -410,7 +397,7 @@
     def _convert_to_compact(self, seconds, millis=True):
         return secs_to_timestr(seconds, compact=True)

-    def _convert_to_clock(self, seconds, millis=True):
+    def _convert_to_timer(self, seconds, millis=True):
return elapsed_time_to_string(seconds * 1000, include_millis=millis)

     def _convert_to_timedelta(self, seconds, millis=True):

--

--- You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to