This excerpt from the Taittiriya Brahmana of the Yajur Veda describes the building of the Savitra altar, during which the names of the days and nights of the Hindu calendar are recited. The Taittiriya Brahmana mentions a story which demonstrates the importance of knowing the names of the days and nights:
Janaka, the king of Videha, met the Days and the Nights. They (these deities, the Days and the Nights) said to him: “Verily, he who knows us will go on living, free from evil; he will attain the full measure of life, he will conquer the heavenly world, and for him food will not waste away in the yonder world.”—Verily, he will go on living, free from evil; he will attain the full measure of life, he will conquer the heavenly world, he who thus knows; and for him food will not waste away in the yonder world.
(A bit redundant, isn't it?) My question is, what is the story of Janaka meeting the gods of the days and nights?
First of all, who is this king Janaka? Most people only know Janaka as the name of Sita's father. But Janaka was the name given to pretty much all the kings of Videha, not just Sita's father, whose personal name was Siradhvaja. However, I think it may refer to Sita's father in this instance, because he is known to have had contact with the gods. When Mithila was under siege by kings who wanted to marry Sita, he got the armies of the gods to help defend the city; see this chapter of the Bala Kanda of the Ramayana.
But does anyone know any scripture which describes Sitaa's father Janaka or any other Janaka meeting with the gods of the days and nights? And who are the gods of the days and nights anyway? The Taittieiya Brahmana gives their names, but is anything more known about them?