“at dusk.” Young men with nothing to do would walk the streets of a city through the evening and night, just as people today go to various places and “just hang out” until the wee hours of the morning.
“the middle of the night and the gloomy darkness.” This phrase confuses people because it cannot be “dusk” and the middle of the night. Many translators try to get around this in their translations, but that is what the text says. The second phrase is somewhat hyperbolic and also metaphorical. It is hyperbolic to show that what is happening between the young man and the adulteress is happening in the dark when people cannot see well, and the “gloomy darkness” is a double entendre for the fact that it is dark outside, and there is also “darkness” in what they are doing—they are “walking in darkness.”
[For more on “gloomy darkness,” see commentary on Prov. 4:19.]