Skip to content

A fun Python script that creates calendars in command line.

Notifications You must be signed in to change notification settings

feelosophy13/calendar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Python Calendar Module

Compatibility

This code was written to support Python 3.x and above. It does not support Python 2.x.

Usage examples

is_leap_year(year)

>>> is_leap_year(2004) 
True
>>> is_leap_year(1900)
False 

is_valid_date(month, date, year)

>>> is_valid_date(2, 31, 2013)
False
>>> is_valid_date(7, 31, 2019)
True

get_days_in_month

>>> get_days_in_month(2, 2008)
29
>>> get_days_in_month(8, 2009)
31

determine_day('mm/dd/yyyy')

 
>>> determine_day('07/06/1990')  # my birthday
Friday
>>> determine_day('01/01/2039')
Saturday

find_start_day_of_month(month, year)

>>> find_start_day_of_month(12, 1964)  # The first day of December in 1964 was the 2nd.
2  

find_start_day_of_month_2(month, year)

>>> find_start_day_of_month_2(12, 1964)  # same functionality as find_start_day_of_month(month, year) but faster
2

draw_month(month, year)

Note: This function does NOT return a value. It just prints a user-friendly visual of the specified month in the command line.
>>> draw_month(7, 1995)
July 1995
Sun   Mon   Tue   Wed   Thu   Fri   Sat
                                      1   

2 3 4 5 6 7 8

9 10 11 12 13 14 15

16 17 18 19 20 21 22

23 24 25 26 27 28 29

30 31

draw_year(year)

Note: This function does NOT return a value. It just prints a user-friendly visual of the specified year's calendar in the command line.
>>> draw_year(2009)
January 2009
Sun   Mon   Tue   Wed   Thu   Fri   Sat
                          1     2     3   

4 5 6 7 8 9 10

11 12 13 14 15 16 17

18 19 20 21 22 23 24

25 26 27 28 29 30 31

February 2009 Sun Mon Tue Wed Thu Fri Sat 1 2 3 4 5 6 7

8 9 10 11 12 13 14

15 16 17 18 19 20 21

22 23 24 25 26 27 28

March 2009 Sun Mon Tue Wed Thu Fri Sat 1 2 3 4 5 6 7

8 9 10 11 12 13 14

15 16 17 18 19 20 21

22 23 24 25 26 27 28

29 30 31

April 2009 Sun Mon Tue Wed Thu Fri Sat 1 2 3 4

5 6 7 8 9 10 11

12 13 14 15 16 17 18

19 20 21 22 23 24 25

26 27 28 29 30

May 2009 Sun Mon Tue Wed Thu Fri Sat 1 2

3 4 5 6 7 8 9

10 11 12 13 14 15 16

17 18 19 20 21 22 23

24 25 26 27 28 29 30

31

June 2009 Sun Mon Tue Wed Thu Fri Sat 1 2 3 4 5 6

7 8 9 10 11 12 13

14 15 16 17 18 19 20

21 22 23 24 25 26 27

28 29 30

July 2009 Sun Mon Tue Wed Thu Fri Sat 1 2 3 4

5 6 7 8 9 10 11

12 13 14 15 16 17 18

19 20 21 22 23 24 25

26 27 28 29 30 31

August 2009 Sun Mon Tue Wed Thu Fri Sat 1

2 3 4 5 6 7 8

9 10 11 12 13 14 15

16 17 18 19 20 21 22

23 24 25 26 27 28 29

30 31

September 2009 Sun Mon Tue Wed Thu Fri Sat 1 2 3 4 5

6 7 8 9 10 11 12

13 14 15 16 17 18 19

20 21 22 23 24 25 26

27 28 29 30

October 2009 Sun Mon Tue Wed Thu Fri Sat 1 2 3

4 5 6 7 8 9 10

11 12 13 14 15 16 17

18 19 20 21 22 23 24

25 26 27 28 29 30 31

November 2009 Sun Mon Tue Wed Thu Fri Sat 1 2 3 4 5 6 7

8 9 10 11 12 13 14

15 16 17 18 19 20 21

22 23 24 25 26 27 28

29 30

December 2009 Sun Mon Tue Wed Thu Fri Sat 1 2 3 4 5

6 7 8 9 10 11 12

13 14 15 16 17 18 19

20 21 22 23 24 25 26

27 28 29 30 31

How leap years are calculated

"The Gregorian calendar, the current standard calendar in most of the world, adds a 29th day to February in all years evenly divisible by 4, except for centennial years (those ending in -00) which are not evenly divisible by 400. Thus 1600, 2000 and 2400 area leap years but 1700, 1800, 1900, 2200 and 2300 are not." - Roger C.

About

A fun Python script that creates calendars in command line.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages