getDayOfYear static method

int getDayOfYear(
  1. DateTime dateTime
)

在今年的第几天

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] as int);
  }
  if (isLeapYearByYear(year) && month > 2) {
    days = days + 1;
  }
  return days;
}