- assert.same({ 2016,7,22,0,0,0 }, { timetable.normalise(2013,42,52,0,0,0) })
- assert.same({ 2016,7,24,2,0,0 }, { timetable.normalise(2013,42,52,50,0,0) })
- end )
-
- it ( "#normalise handles fractional #month" , function ( )
- assert.same({ 2015,2,15,0,0,0 } , { timetable.normalise(2014,14.5,1,0,0,0) })
- assert.same({ 2016,2,15,12,0,0 } , { timetable.normalise(2015,14.5,1,0,0,0) }) -- leap year, so hours is 12
- assert.same({ 2017,2,15,0,0,0 } , { timetable.normalise(2016,14.5,1,0,0,0) })
- end )
-
- it ( "#normalise handles negative carry (issue #10)", function()
- assert.same({ 1970,01,01,00,59,00 }, { timetable.normalise(1970,01,01,01,00,-60) })
- assert.same({ 1970,01,01,00,58,58 }, { timetable.normalise(1970,01,01,01,00,-62) })
- assert.same({ 1969,12,31,23,55,58 }, { timetable.normalise(1970,01,01,01,-63,-62) })
- assert.same({ 2017,02,3,0,0,0 }, { timetable.normalise(2017,02,13,0,-14400,0) })
- end )
+ assert.same({2016,7,22,0,0,0}, {timetable.normalise(2013,42,52,0,0,0)})
+ assert.same({2016,7,24,2,0,0}, {timetable.normalise(2013,42,52,50,0,0)})
+ end)
+
+ it("#normalise handles fractional #month", function()
+ assert.same({2015,2,15,0,0,0}, {timetable.normalise(2014,14.5,1,0,0,0)})
+ assert.same({2016,2,15,12,0,0}, {timetable.normalise(2015,14.5,1,0,0,0)}) -- leap year, so hours is 12
+ assert.same({2017,2,15,0,0,0}, {timetable.normalise(2016,14.5,1,0,0,0)})
+ end)
+
+ it("#normalise handles negative carry (issue #10)", function()
+ assert.same({1970,01,01,00,59,00}, {timetable.normalise(1970,01,01,01,00,-60)})
+ assert.same({1970,01,01,00,58,58}, {timetable.normalise(1970,01,01,01,00,-62)})
+ assert.same({1969,12,31,23,55,58}, {timetable.normalise(1970,01,01,01,-63,-62)})
+ assert.same({2017,02,3,0,0,0}, {timetable.normalise(2017,02,13,0,-14400,0)})
+ end)
+
+ it("#normalise handles negative day carry (issue #13)", function()
+ assert.same({2016,11,30,00,00,00}, {timetable.normalise(2016,12,0,0,0,0)})
+ assert.same({2017,11,30,00,00,00}, {timetable.normalise(2017,12,0,0,0,0)})
+ assert.same({2018,11,30,00,00,00}, {timetable.normalise(2018,12,0,0,0,0)})
+
+ assert.same({2017,2,13,0,0,0}, {timetable.normalise(2017,3,-15,0,0,0)})
+ assert.same({2016,10,1,0,0,0}, {timetable.normalise(2017,3,-150,0,0,0)})
+ assert.same({2013,1,20,0,0,0}, {timetable.normalise(2017,3,-1500,0,0,0)})
+ assert.same({1976,2,4,0,0,0}, {timetable.normalise(2017,3,-15000,0,0,0)})
+ assert.same({1606,6,23,0,0,0}, {timetable.normalise(2017,3,-150000,0,0,0)})
+ end)