getDayOfYear static method

int getDayOfYear(
  1. DateTime dateTime
)

get day of year. 在今年的第几天.

Implementation

static int getDayOfYear(DateTime dateTime) {
  int year = dateTime.year;
  int month = dateTime.month;
  int days = dateTime.day;
  for (int i = 1; i < month; i++) {
    days = days + monthDay[i]!;
  }
  if (isLeapYearByYear(year) && month > 2) {
    days = days + 1;
  }
  return days;
}