]> git.madduck.net Git - etc/awesome.git/blob - .config/awesome/modules/luatz/spec/strftime_spec.lua

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

taghelper module refactoring fixes
[etc/awesome.git] / .config / awesome / modules / luatz / spec / strftime_spec.lua
1 local luatz = require "luatz.init"
2 local time = 1234567890
3 local base_tt = luatz.gmtime(time)
4 describe("#strftime works the same as os.date", function()
5         local strftime = luatz.strftime.strftime
6         for _, spec in ipairs {
7                 "a", "A", "b", "B", "c", "C", "d", "D", "e", "F",
8                 "g", "G", "H", "I", "j", "m", "M", "n", "p", "r",
9                 "R", --[["s",]] "S", "t", "T", "u", "U", "V", "w", "W",
10                 "y", "Y", "z", "Z" , "%"
11         } do
12                 local tt = base_tt:clone()
13                 local f = "%"..spec
14                 local osdf = "!%"..spec
15                 it("format specifier '"..f.."' is equivalent to os.date('"..osdf.."')", function()
16                         for i=1, 365*12 do
17                                 local t = time + 60*60*24*i
18                                 tt.day = tt.day + 1
19                                 tt:normalise()
20                                 assert.are.same(os.date(osdf,t), strftime(f,tt))
21                         end
22                 end)
23         end
24 end)
25 describe("#asctime", function()
26         local asctime = luatz.strftime.asctime
27         it("should format correctly", function()
28                 assert.are.same("Fri Feb 13 23:31:30 2009\n", asctime(base_tt))
29         end)
30 end)