Actor being rotated on pitch get stuck on poles

I’m trying to make a simple day/night cycle based in sun angle, it works mostly except that when it reach 90 or -90 degrees then it get stuck for a while which makes it desync with the clock.
I’ve been reading about this issue and it’s supposed to be called gimbal bug. Not sure if it’s already fixed and I am still doing it wrong.
In any case, can someone tell me how to avoid this problem?
Thanks in advance.