Specify when to stop recurring for a recurring event in Calendar.

I have an event that recurs weekly. It’s a college class. It only lasts one semester, so only a few months. Is there a way to to use AppleScript tell it when to stop repeating?

For example.

Let’s say there’s a math class that starts on March 1 at 3:00PM, 2021, and repeats once a week. I would like this class to stop repeating after July 5, 2021.

I know there are ways to simulate a recurring event by making a separate event for each occurrence, but that seems taxing on my slow 12 inch MacBook.