@ -44,10 +44,28 @@ describe("datetime module", function()
assert.is_equal ( " 00:02:00 " ,
datetime.secondsToClock ( 120 ) )
end )
it ( " should convert seconds to 0d00:00:00 format " , function ( )
assert.is_equal ( " 00:00:00 " ,
datetime.secondsToClock ( 0 , false , true ) )
assert.is_equal ( " 00:02:00 " ,
datetime.secondsToClock ( 120 , false , true ) )
assert.is_equal ( " 5d00:02:00 " ,
datetime.secondsToClock ( 432120 , false , true ) )
end )
it ( " should convert seconds to 0d00:00 format " , function ( )
assert.is_equal ( " 00:00 " ,
datetime.secondsToClock ( 0 , true , true ) )
assert.is_equal ( " 00:02 " ,
datetime.secondsToClock ( 120 , true , true ) )
assert.is_equal ( " 5d00:02 " ,
datetime.secondsToClock ( 432110 , true , true ) )
assert.is_equal ( " 5d00:02 " ,
datetime.secondsToClock ( 432120 , true , true ) )
end )
end )
describe ( " secondsToHClock() " , function ( )
it ( " should convert seconds to 0'00'' format " , function ( )
it ( " should convert seconds to 0' format" , function ( )
assert.is_equal ( " 0' " ,
datetime.secondsToHClock ( 0 , true ) )
assert.is_equal ( " 0' " ,
@ -75,22 +93,38 @@ describe("datetime module", function()
assert.is_equal ( " 10h01' " ,
datetime.secondsToHClock ( 36060 , true ) )
end )
it ( " should round seconds to minutes in 0h 00m format" , function ( )
it ( " should round seconds to minutes in 0h 0m (thinspace) format" , function ( )
assert.is_equal ( " 1m " ,
datetime.secondsToHClock ( 89 , true , true ) )
assert.is_equal ( " 2m " ,
datetime.secondsToHClock ( 90 , true , true ) )
assert.is_equal ( " 2m " ,
datetime.secondsToHClock ( 110 , true , true ) )
assert.is_equal ( " 1h 00m" ,
assert.is_equal ( " 1h \xE2 \x8 0\x89 0m" ,
datetime.secondsToHClock ( 3600 , true , true ) )
assert.is_equal ( " 1h 00m" ,
assert.is_equal ( " 1h \xE2 \x8 0\x89 0m" ,
datetime.secondsToHClock ( 3599 , true , true ) )
assert.is_equal ( " 59m " ,
datetime.secondsToHClock ( 3569 , true , true ) )
assert.is_equal ( " 10h 01m" ,
assert.is_equal ( " 10h \xE2 \x8 0\x89 1m" ,
datetime.secondsToHClock ( 36060 , true , true ) )
end )
it ( " should round seconds to minutes in 0h 0m (hairspace) format " , function ( )
assert.is_equal ( " 1m " ,
datetime.secondsToHClock ( 89 , true , true , false , true ) )
assert.is_equal ( " 2m " ,
datetime.secondsToHClock ( 90 , true , true , false , true ) )
assert.is_equal ( " 2m " ,
datetime.secondsToHClock ( 110 , true , true , false , true ) )
assert.is_equal ( " 1h \xE2 \x80 \x8A 0m " ,
datetime.secondsToHClock ( 3600 , true , true , false , true ) )
assert.is_equal ( " 1h \xE2 \x80 \x8A 0m " ,
datetime.secondsToHClock ( 3599 , true , true , false , true ) )
assert.is_equal ( " 59m " ,
datetime.secondsToHClock ( 3569 , true , true , false , true ) )
assert.is_equal ( " 10h \xE2 \x80 \x8A 1m " ,
datetime.secondsToHClock ( 36060 , true , true , false , true ) )
end )
it ( " should convert seconds to 0h00'00'' format " , function ( )
assert.is_equal ( " 0 \" " ,
datetime.secondsToHClock ( 0 ) )
@ -111,7 +145,7 @@ describe("datetime module", function()
it ( " should change type based on format " , function ( )
assert.is_equal ( " 10h01'30 \" " ,
datetime.secondsToClockDuration ( " modern " , 36090 , false ) )
assert.is_equal ( " 10h 01m30s" ,
assert.is_equal ( " 10h \xE2 \x8 0\x89 1m\xE2 \x80 \x89 30s" ,
datetime.secondsToClockDuration ( " letters " , 36090 , false ) )
assert.is_equal ( " 10:01:30 " ,
datetime.secondsToClockDuration ( " classic " , 36090 , false ) )
@ -125,15 +159,29 @@ describe("datetime module", function()
datetime.secondsToClockDuration ( " modern " , 36090 , false ) )
assert.is_equal ( " 10h02' " ,
datetime.secondsToClockDuration ( " modern " , 36090 , true ) )
assert.is_equal ( " 10h 01m30s" ,
assert.is_equal ( " 10h \xE2 \x8 0\x89 1m\xE2 \x80 \x89 30s" ,
datetime.secondsToClockDuration ( " letters " , 36090 , false ) )
assert.is_equal ( " 10h 02m" ,
assert.is_equal ( " 10h \xE2 \x8 0\x89 2m" ,
datetime.secondsToClockDuration ( " letters " , 36090 , true ) )
assert.is_equal ( " 10:01:30 " ,
datetime.secondsToClockDuration ( " classic " , 36090 , false ) )
assert.is_equal ( " 10:02 " ,
datetime.secondsToClockDuration ( " classic " , 36090 , true ) )
end )
it ( " should pass along withDays " , function ( )
assert.is_equal ( " 58h01'30 \" " ,
datetime.secondsToClockDuration ( " modern " , 208890 , false , false ) )
assert.is_equal ( " 2d10h01'30 \" " ,
datetime.secondsToClockDuration ( " modern " , 208890 , false , true ) )
assert.is_equal ( " 58h \xE2 \x80 \x89 1m \xE2 \x80 \x89 30s " ,
datetime.secondsToClockDuration ( " letters " , 208890 , false , false ) )
assert.is_equal ( " 2d \xE2 \x80 \x89 10h \xE2 \x80 \x89 1m \xE2 \x80 \x89 30s " ,
datetime.secondsToClockDuration ( " letters " , 208890 , false , true ) )
assert.is_equal ( " 58:01:30 " ,
datetime.secondsToClockDuration ( " classic " , 208890 , false , false ) )
assert.is_equal ( " 2d10:01:30 " ,
datetime.secondsToClockDuration ( " classic " , 208890 , false , true ) )
end )
end )
describe ( " secondsToDate() " , function ( )