mirror of
https://github.com/TangentFoxy/lua-date.git
synced 2025-07-28 11:02:17 +00:00
Merge pull request #9 from fertel/master
seconds including fraction used scientific notation if less then 1e-4
This commit is contained in:
2
date.lua
2
date.lua
@@ -599,7 +599,7 @@
|
|||||||
-- Year, if year is in BCE, prints the BCE Year representation, otherwise result is similar to "%Y" (1 BCE, 40 BCE)
|
-- Year, if year is in BCE, prints the BCE Year representation, otherwise result is similar to "%Y" (1 BCE, 40 BCE)
|
||||||
['%\b']=function(self) local x = self:getyear() return fmt("%.4d%s", x>0 and x or (-x+1), x>0 and "" or " BCE") end,
|
['%\b']=function(self) local x = self:getyear() return fmt("%.4d%s", x>0 and x or (-x+1), x>0 and "" or " BCE") end,
|
||||||
-- Seconds including fraction (59.998, 01.123)
|
-- Seconds including fraction (59.998, 01.123)
|
||||||
['%\f']=function(self) local x = self:getfracsec() return fmt("%s%.9g",x >= 10 and "" or "0", x) end,
|
['%\f']=function(self) local x = self:getfracsec() return fmt("%s%.9f",x >= 10 and "" or "0", x) end,
|
||||||
-- percent character %
|
-- percent character %
|
||||||
['%%']=function(self) return "%" end,
|
['%%']=function(self) return "%" end,
|
||||||
-- Group Spec --
|
-- Group Spec --
|
||||||
|
@@ -180,6 +180,9 @@ describe("Testing the 'date' module", function()
|
|||||||
assert(d:fmt('%T') == d:fmt("%H:%M:%S")) -- 24-hour time, from 00:00:00 (06:55:15)
|
assert(d:fmt('%T') == d:fmt("%H:%M:%S")) -- 24-hour time, from 00:00:00 (06:55:15)
|
||||||
assert(d:fmt('%a %A %b %B') == "Tue Tuesday Oct October")
|
assert(d:fmt('%a %A %b %B') == "Tue Tuesday Oct October")
|
||||||
assert(d:fmt('%C %d') == "15 05", d:fmt('%C %d'))
|
assert(d:fmt('%C %d') == "15 05", d:fmt('%C %d'))
|
||||||
|
local d2 = date(1446747300.00008)
|
||||||
|
assert.is.equals(d2:fmt('%\f'),"00.000080109")
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("Tests 'getclockhour()'", function()
|
it("Tests 'getclockhour()'", function()
|
||||||
|
Reference in New Issue
Block a user