Setting time of day based on sun rotation

I had this problem where trying to rotate my sun through SetActorRotation() it was at some point gimbal locked.

I was told to use instead:

Sun->AddActorWorldRotation(FRotator(DeltaTime, 0.f, 0.f));

This fixes the problem above, but how can I translate that to time of day?
For example, I spawn the sun at horizon level then as I add the offset the rotation pitch goes to -90, then back to 0, then 90 and finally back again to 0.

Any idea?

You can still use SetActorRotation():

// Called every frame
void USunRotation::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	// ...
	// 
	// In radians
	float TimeOfDay = fmod(UGameplayStatics::GetRealTimeSeconds(GetWorld()), PI*2.f);
	// In radians
	float Angle = 0.785398; // 45.f

	FVector DirVector = FVector::ForwardVector;

	DirVector = DirVector.RotateAngleAxisRad(TimeOfDay, FVector::RightVector);
	DirVector = DirVector.RotateAngleAxisRad(Angle, FVector::ForwardVector);
	
	GetOwner()->SetActorRotation(DirVector.ToOrientationRotator());
}

TOD