RobotFramework:如何将日期转换为从单个数字天中丢失前导零

时间:2017-07-05 08:45:30

标签: robotframework date-format

见下文。从检查日期格式,%d应该工作,但似乎没有 - 见输出。

Log to console  Completion Date ${completion_date}
${date_to_search_for}=  Convert Date  ${completion_date}  date_format=%Y-%m-%d %H:%m:%S.%f  result_format=%d %b %Y 00:00:00  exclude_millis=True
Log to console  Completion Date ${date_to_search_for}

$ {completion_date}

的输出
Completion Date 2017-07-01 08:37:13.656083

$ {date_to_search_for}

的输出
Completion Date 01 Jul 2017 00:00:00

1 个答案:

答案 0 :(得分:0)

据我所知,文档%d完全按照Custom Timestamp文档中的示例所述。

要获得所需效果,请查看Python datetime示例:

${datetime} =   Convert Date    2014-06-11 10:07:42.123 datetime
Should Be Equal As Integers    ${datetime.year}      2014   
Should Be Equal As Integers    ${datetime.month}         6  
Should Be Equal As Integers    ${datetime.day}           11 
Should Be Equal As Integers    ${datetime.hour}      10 
Should Be Equal As Integers    ${datetime.minute}        7  
Should Be Equal As Integers    ${datetime.second}        42 
Should Be Equal As Integers    ${datetime.microsecond}  123000