Animate the parenting of an object

let's say we have a magazine, a gun, and hands.

The magazine is parented with the gun. When I make an animation of reloading, I want the Magazine to be a parent of the hand, then after the magazine goes back into the gun I want the magazine to be parented with the gun again.

In the above gif, there are two animated empties. The cube follows Empty first, then switches to Empty.001.