[英]How to get the next month in Robotframework
我正在嘗試在 roboframework 中打印下個月並寫下如下內容:
${actual_current_date_t}= 獲取當前日期 result_format=%b %Y
${actual_next_date}= 添加時間到日期 ${actual_current_date_t} 31 天 result_format=%b %Y
登錄到控制台 ${actual_next_date}
但無法打印它。 希望 Output:2023 年 2 月
在這種情況下,將時間添加到日期可能很危險,因為有些月份短於 31 天,這會導致代碼跳過一個月。 這個問題有一些很好的答案,而且很容易將其轉換為 RF: 如何獲得 Python 中下個月的第一天?
*** Settings ***
Library DateTime
Next Month
${new_date}= Evaluate (datetime.datetime.now().replace(day=1)+datetime.timedelta(days=32))
${next_m}= Convert Date ${x} result_format=%b %Y
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.