Along with so much else that we learned about Donald Trump with the release of Friday’s tape — that he likes to “grab them by the p—y,” that being recently married is no impediment to such grabbing, that he has no idea when a microphone is live — we learned that even when Trump tries to apologize, he gets it all wrong. “This was locker room banter,” Trump said on his website, “a private conversation that took place many years ago. Bill Clinton has said far worse to me on the golf course — not even close. I apologize if anyone was offended.” Later in his video apology, he added, “I said it, I was wrong, and I apologize” — which might seem better, but, as we’ll see, is not. If we are to salvage anything from this whole episode, it might be that it causes us to reflect on just what’s wrong with this apology, and how we can get apologies right.

For me, apologizing properly is an especially timely topic, because we are in the week in between the Jewish holidays of Rosh Hashanah and Yom Kippur, the New Year and the Day of Atonement. During this week, it is traditional to reflect on one’s sins, to resolve to do better and, just as important, to apologize to people we have wronged. Judaism has a uniquely clear set of instructions for how to apologize, one that was first elaborated in the late 12th century by the great physician and sage Maimonides, from Cordova, in present-day Spain. And so we might ask: What would Maimonides tell Donald Trump?

Maimonides spelled out his rules for repentance in one of the chapters of the 14-volume Mishneh Torah, completed about 1180. This section, though only a few pages long and little read outside scholarly Jewish circles, is one of the great spiritual documents of the world. The rules are lucid and practical, and they feel absolutely relevant today.

The most important principle in them is that one should seek forgiveness from God only when the sin is against God (cursing God’s name, for example); for sins against a person, one has to atone with that person. “[S]ins between man and man — for example, someone who injures a colleague, curses a colleague, steals from him, or the like — will never be forgiven until he gives his colleague what he owes him and appeases him. . . . Even if a person only upset a colleague by saying [certain] things, he must appease him and approach him [repeatedly] until he forgives him.”

What does this mean for somebody like Trump? Leaving aside the non-apology syntax of Trump’s apology (“if anyone was offended”), he has failed the basic test of choosing the right recipient of his apology. You have to apologize to someone other than the teleprompter. The victim of his act was not the United States, or the electorate; it was the woman or women he was degrading. If, as has been reported, he was speaking about television host Nancy O’Dell, he has to apologize to her. Only when she forgives him are the rest of us at liberty to consider him a repentant.

But what if O’Dell slams the door in his face? Maimonides considers this situation. “If his colleague does not desire to forgive him,” Maimonides writes, the atoner “should bring a group of three of his friends and approach him with them and request [forgiveness].” If the wronged part is still not appeased, Maimonides says the offender should try again, with three other witnesses, and then a third time, with three more, if necessary.” After having tried to apologize in front of nine witnesses, the atoner can give up; he has done what he (or she) can, and now the other party’s to blame for being hardhearted. “[T]he person who refuses to grant forgiveness is the one considered as the sinner.”

One might object that the rule of nine witnesses was fine in a medieval village but sounds rather impractical today. No worries — Maimonides has you covered. Just apologize publicly: “It is very praiseworthy for a person who repents to confess in public and to make his sins known to others, revealing the transgressions he committed against his colleagues.” But again, the sin must be confessed specifically, and the apology must be directed toward the injured parties, like O’Dell, and, I would suggest, Melania Trump, who was pregnant with Trump’s child when he made the comments that were caught on tape.

Maimonides’s rules are not comprehensive enough for today’s world. If you want to know whether an apology can be texted or Facebooked, you can’t look for answers in the 12th century, and many Yom Kippur sermons, of the kind that will be given across the world Wednesday, deal with these modern apology dilemmas. And rabbis recognize that these rules hide certain complexities. (What if O’Dell would rather not hear from you? It may be best not to retraumatize her with your apology.) But certain principles are timeless. Above all, Maimonides recognized that the apology must reflect a sincere commitment not to sin again. “Who has reached complete teshuvah?” he asked, using the Hebrew word for repentance. “A person who confronts the same situation in which he sinned” but this time “abstains and does not commit it” again.

Judaism is clear that we are all sinners, which is why all Jews must recite a sinner’s prayer on Yom Kippur. And it is also clear that one can repent right up until death: “Even if he transgressed throughout his entire life and repented on the day of his death and died in repentance, all his sins are forgiven,” Maimonides writes. But Judaism teaches that when that repentance comes, it must involve an attempt to make amends to the specific people he has wronged — the contractors he stiffed, the Trump University students whose money he leached, the women he groped, O’Dell herself. Trump could stand to learn something from the Jewish tradition, because he’s certainly not given the last apology he owes.