4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Python] プレミアムフライデー判定

Last updated at Posted at 2017-10-27

今日はプレミアムフライデーですね。

# -*- coding: utf-8 -*-

import datetime
import calendar

def get_premium_friday_list(year):
    pre_fri_list = []
    for month in range(1, 13):
        lastfri = max(week[calendar.FRIDAY] for week in calendar.monthcalendar(year, month))
        pre_fri = '{}-{}-{}'.format(year, month, lastfri)
        pre_fri_list.append(pre_fri)
    return pre_fri_list

def main():
    now = datetime.datetime.now()
    date = now.strftime('%Y-%m-%d')
    if date in get_premium_friday_list(now.year):
        # プレ金だったときのなにか

if __name__ == '__main__':
    main()
4
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?