The variable that you get from robot is a string so you should parse
an integer from that before doing anything else (hour == 0 will be
false when "0" == 0).
hour * 1 does nothing.
The modulo operator '%' is quite convenient when doing the kind of
things you are doing.
Cheers,
Mikko Korpela
2011/5/18 markg <mgib...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "robotframework-users" group.
> To post to this group, send email to robotframe...@googlegroups.com.
> To unsubscribe from this group, send email to robotframework-u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.
>
>
As Mikko just commented, you should do this integer conversion
earlier. If you don't, comparisons like `hour >= 12` don't work as you
expect. In code you should do this instead:
def return_twelve_hour_time(hour):
hour = int(hour)
if hour >= 12:
return hour - 12
elif hour == 0:
return 12
else:
return hour
You might also want to consider using Python's time [1] or datatime
[2] modules to get the current hour automatically into your keyword.
It would make using your keyword easier as you didn't need to use `Get
Time` keyword before.
[1] http://docs.python.org/library/time.html
[2] http://docs.python.org/library/datetime.html
Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org