private void Update() { CalenderDate date = EventCalender.Instance.Date; seconds.text = "Seconds: " + date.second; minutes.text = "Minutes " + date.minute; hours.text = "Hours: " + date.hour; days.text = "Days: " + date.day; months.text = "Months: " + date.month; years.text = "Years: " + date.year; }
private void Update() { CalenderDate date = EventCalender.Instance.Date; float hourPercentage = date.hour / (float)CalenderDate.CLOCK_HOURS_PER_DAY; hourPercentage -= date.hour > CalenderDate.CLOCK_HOURS_PER_DAY ? 1.0f : 0.0f; bigPointer.transform.localEulerAngles = new Vector3(0, 0, -(hourPercentage * MAX_DEGREES)); float minutesPercentage = date.minute / (float)CalenderDate.MINUTES_PER_HOUR; smallPointer.transform.localEulerAngles = new Vector3(0, 0, -(minutesPercentage * MAX_DEGREES)); }
// Complete the dayOfProgrammer function below. static string dayOfProgrammer(int year) { //Leap Year Rules: //Divisible by 400 //divisble by 4 and not by 100 //Output format dd.mm.yyyy bool MinYear_Check = year < 1700; bool MaxYearCheck = year > 2700; if (!MinYear_Check && !MaxYearCheck) //check for invalid year { int[] leapYeardays = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; //hold leap year days of each month int[] NonLeapYear = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; //hold non leap year days of each month int sum = 0; //to hold the value of the sum of the first 8 months int dayleft; //to hold the value of the days left after subtractinf 256 from the sum variable const int programmerday = 256; //constant programmer string CalenderDate; //to hold the value for the formated date //Since the transition occured on 1918 and Feb 14th was the 32 day of the year, we will assume that there were only 15 days Feb for that year int sum_of_8months = 230; int Day_of_9th_Month = (programmerday - sum_of_8months); if (year == 1918) { Console.WriteLine(); return(Day_of_9th_Month.ToString() + "." + "09." + year); } //Gregorian and Julian Leap Programmer Day Calulator if ((year >= 1919 && (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))) || (year <= 1917 && year % 4 == 0)) { var First8Months = new ArraySegment <int>(leapYeardays, 0, 8); //take the first 8 element foreach (var day in First8Months) { sum += day; //sum up the first 8 months days } dayleft = (programmerday - sum); //get the remainder of days left by subtracting 256 from the sum variable CalenderDate = dayleft + "." + "09." + year; //output format Console.WriteLine(); return(CalenderDate.ToString()); //return the ooutput } //else if none of the year is a Leap year in either the gregorian or the julian calender then calculate the 256th day else { var First8Months = new ArraySegment <int>(NonLeapYear, 0, 8); //take the first 8 element foreach (var day in First8Months) { sum += day; //sum up the first 8 months days } dayleft = (programmerday - sum); //get the remainder of days left by subtracting 256 from the sum variable CalenderDate = dayleft + "." + "09." + year; //output format Console.WriteLine(); return(CalenderDate.ToString()); //return the output } } else //if the year is invalid then { Console.WriteLine("Input Validation"); } return(""); }