c# - Calculating a leap year without the leap year function -
i need calculate if current year @ runtime of program leap year (divisible 4, not divisible 100 divisible 400) without using datetime.leapyear property. can suggest anything?
//datetimepicker code
private void datetimepicker1_valuechanged(object sender, eventargs e) { datetime now; int[] months = {31,28,31,30,31,30,31,31,30,31,30,31}; = datetime.now.date; if (now.year / 4 == 0 && now.year / 400 == 0) { months(1) = 29; } }
i think covers 3 criteria:
var year = now.year; if (year % 4 == 00 && !(year % 100 == 0 && year % 400 != 0)) { .... }
Comments
Post a Comment