checkio The First Working Day

题目:
As the input you’ll get the date of the first vacation day in the format ‘YYYY-MM-DD’ and the total number of vacation days. Your task is to find out which day will be the first working day after the vacation. If it’ll be Saturday or Sunday then it should be the next Monday.
In this mission you have to ignore national holidays and consider only Saturdays and Sundays.
Also don’t forget about February 29th in the leap year and the situation when the vacation starts at the end of December of the one year and ends at the beginning of the next year.

Input: The first day of the vacation and the number of days in it.

Output: The date of the first working day.

Example:

vacation(‘2018-07-01’, 14) == ‘2018-07-16’
vacation(‘2018-02-19’, 10) == ‘2018-03-01’
vacation(‘2000-02-28’, 5) == ‘2000-03-06’
vacation(‘1999-12-20’, 14) == ‘2000-01-03’
链接:
https://py.checkio.org/en/mission/the-first-working-day/

代码:

from datetime import date
from datetime import datetime
def vacation(d, days):

    dd = datetime.strptime(d, '%Y-%m-%d')
    rel = 0
    while rel < days:
        dd += date.resolution
        rel += 1

    while dd.isoweekday() >=6 :
         dd += date.resolution
    return str(dd.date())
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值