It’s clear that its origin must be Valencian, but we must go back to the time when the city had walls. They were finally demolished in the 19th century.
The walls, during the day, had their doors open and when the sun went down, they closed them so that strangers and bad people would not enter the city. The last door to close was the Serrans Gate, because it was the one to the west and we all know that the sun rises in the east and sets in the west.
Then those who were distracted or staring and did not arrive in time to enter before it got dark, had to spend the night on the flat, with the only distraction of contemplating the moon.
From here it comes the expression “Being on the Moon of Valencia”, to refer to that person who is bathing, thinking about shrews, etc.
Wooow! No sabia el seu origen! Gràcies!