But we know from TOS that people in Star Trek do not go to jail for punishment. People in Star Trek go to jail because that's how they facilitate forced psychological reconditioning. There is no punitive aspect to the jailing, because crime is not considered to be cured by punishment - it's a mental illness cured by therapy. There probably isn't even a trial involved, but rather a medical hearing where doctors decide which sort of therapy the patient is to receive.
If you can be programmed not to do it again in X number of sessions (and indeed UFP medicine seems to achieve that pretty well), then there is no reason to hold you in prison beyond that. Temporary lockings-up in shipboard or stationboard gaols serve a different function - they prevent a person from disappearing, or from harming people or property around him, until the person can either be subjected to psycho-corrective treatment or deemed sobered-up or otherwise calmed down.
We're thus left to wonder why anybody, be it Odo or Sisko or their superiors, would choose to lock up Garak in a holding cell for half a year. We could just as well say that Garak completely misunderstood his sentence - he thought he was going in for the punitive aspect (and thus rightfully commented that the sentence was awfully short), whereas in reality he was confined for his forced therapy only, and this therapy allowed him considerable freedom of movement and action (just like Tom Paris did make-work in "Caretaker"), explaining possible references to other characters interacting with him.
...Although I can just imagine how deep yer standard UFP shrink would get into Garak's skull before he or she gave up, weeping...
As regards Yates' and Garak's sentence lengths, Yates was captured at an unknown stardate that supposedly preceded the SD 49904 of the next episode. She was released at an unknown stardate that supposedly preceded the SD 50416 of the next episode. 500 stardates is more or less six months in TNG-era thinking, at least in theory - but here the theory seems to have been put in practice, so probably somebody was keeping track.
Garak was captured in SD49962 or so. He was first seen released at an unknown stardate in the middle of a long string of stardate-less episodes - and nothing in the episode really demanded that it precede the one where Yates was released. Yet conveniently, we need not really reshuffle anything, because neither "Things Past" nor the intervening "The Ascent" are episodes that would take weeks upon weeks of the lives of our heroes. Essentially, "Things Past", "The Ascent" and "Rapture" could all have happened on the very same week, rendering moot the point that we saw Garak on the loose before we saw Yates.
Timo Saloniemi