check what is value d and hr. Does they matched the if and else-if condition?