As I was testing various activities for my commoner ai I realized that my "sleeping" commoners would get up and pick another activity at the time period change, meaning they wouldn't be asleep for a normal amount of time. I also realized there was no way for them to go home for the night (only sleep in the same area was allowed). So I've added a new activity and some new functionality that I'm currently working out bugs in. You can now give a "go home and sleep" activity and commoners will find and move to a random door in the area, play the "use" animation, and go script hidden for 9 hours (8+1 for breakfast). At their wake up time they unhide themselves and pick a new activity based on the time. Once that is working, I will add the code to force the activity for a sleep period to all the sleep activity functions, and add a sleep until morning and a sleep until evening function.
The go home and sleep functions will allow builders to have their streets empty out at night (or day if you want vampire commoners :) ). Since these are command to essentially "leave the area", I could see them being used to empty out a tavern at closing time or give a shop hours, with the timely player being able to see these transitions.
Another use case for the commoner ai would be for something like a tavern, have the patrons sit and eat during the day, and get up and dance or play instruments at night, automatically.
edit: it looks like I've solved my problem with npc's sometimes getting stuck at their old waypoint when they pick a new activity. Pesky bug solved! And now my npc's also are "sleeping" properly in their go home and sleep activity, so I can add the sleep period code to the other sleep activities.