[ create a new paste ] login | about

Link: http://codepad.org/V2zSXyTP    [ raw code | output | fork ]

Python, pasted on Jun 26:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import datetime

FRIDAY = 4
MONTHS_TO_CHECK = (1, 3, 5, 7, 8, 10, 12)

def check_1st_friday(day):
    if day.weekday() == FRIDAY:
        return True
    return False

        
if __name__ == "__main__":
    year_from = 2000
    year_to = 2020

    for year in range(year_from, year_to + 1):
        for month in MONTHS_TO_CHECK:
            day = datetime.date(year, month, 1)
            if check_1st_friday(day):
                print day


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2000-12-01
2002-03-01
2003-08-01
2004-10-01
2005-07-01
2006-12-01
2008-08-01
2009-05-01
2010-01-01
2010-10-01
2011-07-01
2013-03-01
2014-08-01
2015-05-01
2016-01-01
2016-07-01
2017-12-01
2019-03-01
2020-05-01


Create a new paste based on this one


Comments: