B4X:
Public Sub GetNumberOfDaysInYear(Year As Int) As Int
Return DateUtils.PeriodBetweenInDays(DateUtils.SetDate(Year,1,1),DateUtils.SetDate(Year,12,DateUtils.NumberOfDaysInMonth(12,Year))).Days +1
End Sub
B4X:
Public Sub GetNumberOfDaysInYear2(Year As Int) As Int
Return DateTime.GetDayOfYear(DateUtils.SetDate(Year,12,31))
End Sub
from @mcqueccu
B4X:
Public Sub GetNumberOfDaysInYear3(Year As Int) As Int
DateTime.DateFormat = "yyyy/MM/dd"
Dim d As Long = DateTime.DateParse($"${Year}/12/31"$)
Return DateTime.GetDayOfYear(d)
End Sub
from @epiCode
B4X:
Sub GetDaysInYear(year As Int) As Int
Return IIf((year Mod 4 = 0 And year Mod 100 <> 0) Or year Mod 400 = 0, 366, 365)
End Sub
Last edited: