generate calendar function