transform.rotation.z gives different value than expected

I’m got a game object that has it’s z-axis rotated to a new position when the scene starts, based on the time of day. I want the color of the game object to change depending on how many degrees the object’s z-axis rotation is at. The if statements are failing because the value I’m getting returned is less than 1.0, but the rotation in the editor says it’s like 221 degrees.

What am I missing here?
note this isn’t the whole script, I didn’t copy over anything not related to this issue.

The IF statements in the getSunState() always execute the first one because the results of this.transform.rotation.z always com in below “1”.

//Lerp colors of sun to simulate sunrise
function sunRise(){
	Debug.Log("sunRise called 3");
	sun.color = Color.Lerp (sunNightColor, sunDayColor, Time.deltaTime * 21600);
}

//Lerp colors of sun to simulate sunset
function sunSet(){
	Debug.Log("sunSet called 3");
	sun.color = Color.Lerp (sunDayColor, sunNightColor, Time.deltaTime * 28800);
}

function getSunState() {
Debug.Log("getSetState called 2");
Debug.Log("transform.rotation.z = " + transform.rotation.z);
	while (normalPassageOfTime == true) {
		if (transform.rotation.z > 75 && transform.rotation.z < 120) {
			sunRise();
		}
		if (this.transform.rotation.z >= 120 && this.transform.rotation.z < 240) {
			sun.color = sunDayColor;
			Debug.Log("Sun color set to Day 3");
		}
		if (this.transform.rotation.z >= 240 && this.transform.rotation.z < 285) {
			sunSet();
		}
		if (this.transform.rotation.z >= 165 || this.transform.rotation.z <= 75) {
			sun.color = sunNightColor;
		}
		yield;
	}
}

//set position of the sun based on time of day
function setSun() {
	Debug.Log("setSun function works 1");
	transform.Rotate(0,0,degreesOfRotation * (hoursInSeconds + minutesInSeconds));
	getSunState();
	Debug.Log("z rotation = " + this.transform.rotation.z);
	Debug.Log("sunRise called 3");
}



//rotate the sun based on set speed
function moveSun() {
	while (speedOfLight > 0) {
		//Multiplies speed variable by number of degrees to rotate per second
		speedModifier = degreesOfRotation * speedOfLight;
		transform.Rotate(0,0,speedModifier * Time.deltaTime);
		yield;	
	}
}

function Start () {
	
	normalPassageOfTimeToggle();
	importVariables();
	if (normalPassageOfTime == true) {
		setClockHour();
		transform.rotation = Quaternion.identity;
		setSun();
		moveSun();
	}
	
	//Debug.Log("TODPhrase within Start function is " + timeOfDayPhrase);
	//Debug.Log("clockHour within Start function is " + clockHour);
}

As you can see in the transform.rotation documentation, that value is of the Quaternion type.

Reading and writing directly to the component values of a quaternion is not really a thing. They don’t exactly have meaning apart from their mathematical relationship to their sibling values, and are not for humans to manipulate. Quaternions are for computers to deal with.

You can use basic trigonometry and the Vector3 and Quaternion class methods to achieve all the rotation-related goals you’ll have in Unity. When you need to work directly with specific angle or radian values, you can use those formula and methods which take or return those units. Which formula or method to use varies case by case, and is something you’ll pick up as you encounter and research specific needs. Eventually it’ll click - how certain approaches work better in certain cases - after which you’ll rarely struggle with rotation-related goals.