Hi there and thank you for your question,
I will try to assist you with your legal question but please feel free to ask as many follow up questions as you like until you are 100% satisfied.
In short, No, they are not acting in accordance with the law.
I don't see any way or reason that they can enforce such a limitation. If the pensioners were living in an ICU unit at a hospital, sure - but no ways in a block of flats.
You do need to be aware that the block might have rules requiring guests to sign in at security, or such like - but to limit the times when one can expect a visitor can't past muster. That would most certainly be an infringement on people's constitutional rights.
My advice is for all of the residents to get together and write a letter (signed by everyone) to the municipality (as landlord) and tell the municipality that the new rule is arbitrary, and illogical; that it serves no purpose; that it infringes on their constitutional rights; and that nobody is going to abide by the rule.
Ask the municipality to revoke the rule with immediate effect.
Unfortunately if the municipality enforces the rule through security guards or such like, then the residents will need to hire an attorney and go to court to challenge the rule.
If my answer hasn't answered all of your questions, please send me a REPLY with follow up questions so that I can continue to assist you in this same thread for as long as you need. Let me know if you need more advice - dont just rate my answer as "bad".
If my are HAPPY with my answer then please click one of the STAR ratings or the SMILEY FACES to rate my answer!
Good luck and best regards,