TimeTrackerController.setSimulationStartTime C# (CSharp) Method

setSimulationStartTime() public method

Sets the sim start time. FORMAT = 00:00:00 AM
public setSimulationStartTime ( string timeOfDay ) : void
timeOfDay string Time of day as string. //format should be .. 00:00:00 am
return void
	public void setSimulationStartTime(string timeOfDay) {


		//separate the string into parts.
		string hours = new string(timeOfDay.ToCharArray(0,2));
		string minutes = new string(timeOfDay.ToCharArray(3,2));
		string seconds = new string(timeOfDay.ToCharArray(6,2));
		string ampm = new string (timeOfDay.ToCharArray(9,2));

		//convert to ints.
		int hourSeconds = int.Parse(hours) * 3600;
		int minuteSeconds = int.Parse(minutes) * 60;
		int secs = int.Parse(seconds);

		if (ampm.ToLower() == "pm") hourSeconds += 43200; //add 12 hours worth of seconds if pm.

		//add up the seconds.
		int totalSecs = hourSeconds + minuteSeconds + secs;

		//set new.
		timeTracker.setSimStartTime(totalSecs);
		Debug.Log(timeTracker.getSimStartTime());

	}