Changed the conditionals for handling the first day of the month

@ramlev please look at this one.