|
322 | 322 | @test yearfrac(Date(2012, 2,28), Date(2011,12,28), dc) == -yearfrac(Date(2011,12,28), Date(2012, 2,28), dc) |
323 | 323 | @test yearfrac(Date(2012, 3,28), Date(2012, 2,29), dc) == -yearfrac(Date(2012, 2,29), Date(2012, 3,28), dc) |
324 | 324 | end |
| 325 | + |
| 326 | + |
| 327 | + |
| 328 | +@testset "ActualActualExcel" begin |
| 329 | + dc = DayCounts.ActualActualExcel() |
| 330 | + # calculated from Excel sheet |
| 331 | + @test yearfrac(Date(2011,12,28), Date(2012, 2,28), dc) == 62/365 |
| 332 | + @test yearfrac(Date(2011,12,28), Date(2012, 2,29), dc) == 63/366 |
| 333 | + @test yearfrac(Date(2011,12,28), Date(2012, 3, 1), dc) == 64/366 |
| 334 | + @test yearfrac(Date(2011,12,28), Date(2016, 2,28), dc) == 1523/365.3333333333333 |
| 335 | + @test yearfrac(Date(2011,12,28), Date(2016, 2,29), dc) == 1524/365.3333333333333 |
| 336 | + @test yearfrac(Date(2011,12,28), Date(2016, 3, 1), dc) == 1525/365.3333333333333 |
| 337 | + @test yearfrac(Date(2012, 2,28), Date(2012, 3,28), dc) == 29/366 |
| 338 | + @test yearfrac(Date(2012, 2,29), Date(2012, 3,28), dc) == 28/366 |
| 339 | + @test yearfrac(Date(2012, 3, 1), Date(2012, 3,28), dc) == 27/366 |
| 340 | + |
| 341 | + @test yearfrac(Date(2012, 2,28), Date(2013, 2,28), dc) == 366/366 |
| 342 | + @test yearfrac(Date(2012, 2,29), Date(2013, 2,28), dc) == 365/366 |
| 343 | + @test yearfrac(Date(2012, 3, 1), Date(2013, 2,28), dc) == 364/365 |
| 344 | + @test yearfrac(Date(2012, 2,28), Date(2013, 3, 1), dc) == 367/365.5 |
| 345 | + @test yearfrac(Date(2012, 2,29), Date(2013, 3, 1), dc) == 366/365.5 |
| 346 | + @test yearfrac(Date(2012, 3, 1), Date(2013, 3, 1), dc) == 365/365 |
| 347 | + |
| 348 | + @test yearfrac(Date(2011, 2,28), Date(2012, 2,28), dc) == 365/365 |
| 349 | + @test yearfrac(Date(2011, 3, 1), Date(2012, 2,28), dc) == 364/365 |
| 350 | + @test yearfrac(Date(2011, 2,28), Date(2012, 2,29), dc) == 366/365.5 |
| 351 | + @test yearfrac(Date(2011, 3, 1), Date(2012, 2,29), dc) == 365/366 |
| 352 | + @test yearfrac(Date(2011, 2,28), Date(2012, 3, 1), dc) == 367/365.5 |
| 353 | + @test yearfrac(Date(2011, 3, 1), Date(2012, 3, 1), dc) == 366/366 |
| 354 | + |
| 355 | + # zeros |
| 356 | + @test yearfrac(Date(2011,12,28), Date(2011,12,28), dc) == 0 |
| 357 | + @test yearfrac(Date(2011,12,31), Date(2011,12,31), dc) == 0 |
| 358 | + @test yearfrac(Date(2012, 2,28), Date(2012, 2,28), dc) == 0 |
| 359 | + @test yearfrac(Date(2012, 2,29), Date(2012, 2,29), dc) == 0 |
| 360 | + |
| 361 | + # reflection |
| 362 | + @test yearfrac(Date(2012, 2,28), Date(2011,12,28), dc) == -yearfrac(Date(2011,12,28), Date(2012, 2,28), dc) |
| 363 | + @test yearfrac(Date(2012, 3,28), Date(2012, 2,29), dc) == -yearfrac(Date(2012, 2,29), Date(2012, 3,28), dc) |
| 364 | +end |
| 365 | + |
| 366 | +include("excel.jl") |
0 commit comments