Changeset 263
 Timestamp:
 May 30, 2007, 9:25:47 PM (17 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Include/Classes/System/DateTime.ab
r246 r263 133 133 134 134 Function Day() As Long 135 Return DayOfYear  totalDaysOfMonth s(Year, Month  1)135 Return DayOfYear  totalDaysOfMonth(Year, Month  1) 136 136 End Function 137 137 … … 140 140 Dim day = DayOfYear As Long 141 141 Dim i = 1 As Long 142 While day > totalDaysOfMonth s(year, i)142 While day > totalDaysOfMonth(year, i) 143 143 i++ 144 144 Wend … … 148 148 Function Year() As Long 149 149 Dim day = (Ticks \ TimeSpan.TicksPerDay) As Long 150 Dim year = Int((day + day \ 36524  day \ 146097) / 365.25) As Long151 If day  totalDaysOfYears(year) + 1 = 366 Then150 Dim year = Int((day + day \ 36524  day \ 146097) / 365.25) + 1 As Long 151 If day  yearToDay(year  1) + 1 = 366 Then 152 152 Return year + 1 153 153 Else … … 157 157 158 158 Function DayOfWeek() As Long 'As DayOfWeek 159 Return ((Ticks \ TimeSpan.TicksPerDay) Mod 7) As Long 1159 Return ((Ticks \ TimeSpan.TicksPerDay) Mod 7) As Long + 1 160 160 End Function 161 161 … … 165 165 166 166 Function DayOfYear() As Long 167 Return ((Ticks \ TimeSpan.TicksPerDay)  totalDaysOfYears(Year) + 1) As Long167 Return ((Ticks \ TimeSpan.TicksPerDay)  yearToDay(Year) + 1) As Long 168 168 End Function 169 169 … … 244 244 245 245 Function AddYears(value As Double) As DateTime 246 Dim additionYear = Year + Int(value) 247 Dim ticks = totalDaysOfYears(additionYear) * TimeSpan.TicksPerDay + DayOfYear() * TimeSpan.TicksPerDay 248 249 If IsLeapYear(additionYear) Then 246 Dim date = New DateTime(Year + Int(value), Month, Day, Hour, Minute, Second, Millisecond, Kind) 247 Dim ticks = Ticks _ 248  (yearToDay(Year) + totalDaysOfMonth(Year, Month  1) + Day  1) * TimeSpan.TicksPerDay _ 249  Hour * TimeSpan.TicksPerHour _ 250  Minute * TimeSpan.TicksPerMinute _ 251  Second * TimeSpan.TicksPerSecond _ 252  Millisecond * TimeSpan.TicksPerMillisecond As Int64 253 If IsLeapYear(Year + Int(value)) Then 250 254 ticks += (value  Int(value)) * 366 * TimeSpan.TicksPerDay 251 255 Else 252 256 ticks += (value  Int(value)) * 365 * TimeSpan.TicksPerDay 253 257 End If 254 255 Return New DateTime(ticks, Kind) 258 Return date.AddTicks(ticks) 256 259 End Function 257 260 … … 389 392 390 393 initialize( 391 totalDaysOfYears(year) * TimeSpan.TicksPerDay _392 + totalDaysOfMonth s(year, month  1) * TimeSpan.TicksPerDay _394 yearToDay(year) * TimeSpan.TicksPerDay _ 395 + totalDaysOfMonth(year, month  1) * TimeSpan.TicksPerDay _ 393 396 + (day  1) * TimeSpan.TicksPerDay _ 394 397 + hour * TimeSpan.TicksPerHour _ … … 446 449 End Function 447 450 448 Static Function totalDaysOfYears(year As Long) As Long 451 Static Function yearToDay(year As Long) As Long 452 year 449 453 Return (Int(year * 365.25)  Int(year * 0.01) + Int(year * 0.0025)) 450 454 End Function 451 455 452 Static Function totalDaysOfMonth s(year As Long, month As Long) As Long456 Static Function totalDaysOfMonth(year As Long, month As Long) As Long 453 457 Dim days As Long 454 458 Dim i As Long
Note:
See TracChangeset
for help on using the changeset viewer.