Reputation: 11872
I want create in RobotFramework a function that return next saturday.
*** Settings ***
Library SeleniumLibrary
Library DateTime
*** Keywords ***
Get Next saturday
${today}= Get Time
${today_day}= Convert Date ${today} result_format=%a
${next_saturday}= ????
${next_saturday_formated}= Convert Date ${next_saturday} result_format=%d/%m/%Y
[Return] ${next_saturday_formated}
Before ask this question I try with
${next_saturday}= Set Variable If "${today_day}"=="Fri" ...
Upvotes: 0
Views: 894
Reputation: 1569
Using keyword Get Current Date
you could get weekday index and calculate number of days before Saturday and then using number of days generate date from the future. Final keyword would look like this:
Get Next Saturday
${day_index} Get Current Date result_format=%w
${till_saturday} Evaluate 6 - ${day_index}
${saturday} Get Current Date increment=${till_saturday} days result_format=%d/%m/%Y
Return From Keyword ${saturday}
Upvotes: 5