days2mdhms function
Implementation
LocalDate days2mdhms(num year, num days) {
final lmonth = [
31,
(year % 4) == 0 ? 29 : 28,
31,
30,
31,
30,
31,
31,
30,
31,
30,
31
];
final dayofyr = days.floor();
// ----------------- find month and day of month ----------------
var i = 1;
var inttemp = 0;
while ((dayofyr > (inttemp + lmonth[i - 1])) && i < 12) {
inttemp += lmonth[i - 1];
i += 1;
}
final mon = i;
final day = dayofyr - inttemp;
// ----------------- find hours minutes and seconds -------------
var temp = (days - dayofyr) * 24.0;
final hr = temp.floor();
temp = (temp - hr) * 60.0;
final minute = temp.floor();
final sec = (temp - minute) * 60.0;
return LocalDate(
mon: mon,
day: day,
hr: hr,
minute: minute,
sec: sec,
);
}