Your explanation seems a little confusing, but my understanding would be:
1. get_day function to return whether day is GOOD or BAD .... to me this would mean placing an echo at the end of the function as you need to return a string
2. internally to the function you will need local variables for the following:
DAY - would pick an alternate name here so to not get confused ... maybe retval (I am using lower case as upper is usually reserved for environment variables)
FIRSTDIGIT
SECONDDIGIT
DD
CALENDER - this one may be tricky as it is an array ... is it used elsewhere?
---
I wanted to mention previously that I am not sure why you use the outer if that tests FIRSTDIGIT ... if you test as a number it will remove the leading zero
Hope some of that helps
If not, please advise which points I am mistaken about?