Compute monthly date/time boundaries
from calendar import monthrange
from datetime import datetime, timedelta
def month_boundaries(year, month):
start = datetime(year, month, 1)
month_days = monthrange(year, month)[1]
return [start, start + timedelta(days=month_days, seconds=-1)]
if __name__ == '__main__':
import sys
print(month_boundaries(int(sys.argv[1]), int(sys.argv[2])))