In can be used for talking about periods of time and when something is going to happen after a known period of time from now.
My birthday is in July.
I'm starting my new job in six days time.
In your example it should be something like "Her husband ran out on her after two months"
As for your second question "Building codes" are rules about where and how buildings are constructed. For example the size of windows, how many storeys and things like that.
I'm not sure exactly what "openings" are without the full context but they are something that rules have been written about.
- For Teachers