mirror of
https://github.com/TangentFoxy/lua-date.git
synced 2025-07-27 18:42:18 +00:00
housekeeping, adding CI, moving some source files, fix linter
This commit is contained in:
8
.busted
8
.busted
@@ -1,5 +1,11 @@
|
||||
return {
|
||||
default = {
|
||||
output = "TAP"
|
||||
verbose = true,
|
||||
coverage = true,
|
||||
output = "gtest",
|
||||
ROOT = {
|
||||
"spec/",
|
||||
--"examples/vcache.lua",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
13
.editorconfig
Normal file
13
.editorconfig
Normal file
@@ -0,0 +1,13 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
|
||||
[*.lua]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.DS_store
|
||||
luacov.*
|
31
.luacheckrc
Normal file
31
.luacheckrc
Normal file
@@ -0,0 +1,31 @@
|
||||
--std = "ngx_lua+busted"
|
||||
unused_args = false
|
||||
redefined = false
|
||||
max_line_length = false
|
||||
|
||||
|
||||
globals = {
|
||||
--"_KONG",
|
||||
--"kong",
|
||||
--"ngx.IS_CLI",
|
||||
}
|
||||
|
||||
|
||||
not_globals = {
|
||||
"string.len",
|
||||
"table.getn",
|
||||
}
|
||||
|
||||
|
||||
ignore = {
|
||||
--"6.", -- ignore whitespace warnings
|
||||
}
|
||||
|
||||
|
||||
exclude_files = {
|
||||
"here/**",
|
||||
"samples/**",
|
||||
--"spec/fixtures/invalid-module.lua",
|
||||
--"spec-old-api/fixtures/invalid-module.lua",
|
||||
}
|
||||
|
6
.luacov
Normal file
6
.luacov
Normal file
@@ -0,0 +1,6 @@
|
||||
modules = {
|
||||
["date"] = "src/date.lua",
|
||||
["date.*"] = "src"
|
||||
}
|
||||
runreport = true
|
||||
deletestats = false
|
45
.travis.yml
45
.travis.yml
@@ -1,28 +1,29 @@
|
||||
language: erlang
|
||||
language: python
|
||||
sudo: false
|
||||
|
||||
env:
|
||||
- LUA="luajit-2.0.0-beta9"
|
||||
- LUA="lua 5.1"
|
||||
- LUA="lua 5.2"
|
||||
- LUA="lua 5.3"
|
||||
- LUA="luajit 2.0"
|
||||
- LUA="luajit 2.0 --compat 5.2"
|
||||
- LUA="luajit 2.1"
|
||||
- LUA="luajit 2.1 --compat 5.2"
|
||||
|
||||
before_install:
|
||||
- pip install hererocks
|
||||
- hererocks here -r^ --$LUA
|
||||
- source here/bin/activate
|
||||
- luarocks install luacheck
|
||||
- luarocks install busted
|
||||
- luarocks install luacov-coveralls
|
||||
|
||||
install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq git luajit luarocks
|
||||
- sudo ln -s /usr/bin/luajit-2.0.0-beta9 /usr/bin/luajit
|
||||
- sudo luarocks install busted
|
||||
- git clone git://github.com/Tieske/date.git
|
||||
- cd date
|
||||
- luarocks make
|
||||
|
||||
script: "sudo busted"
|
||||
|
||||
notifications:
|
||||
webhooks:
|
||||
- http://exobot.herokuapp.com/hubot/travis
|
||||
recipients:
|
||||
- thijs@thijsschreijer.nl
|
||||
email:
|
||||
on_success: always
|
||||
on_failure: always
|
||||
|
||||
branches:
|
||||
except:
|
||||
- gh-pages
|
||||
script:
|
||||
- luacheck .
|
||||
- busted
|
||||
|
||||
after_success:
|
||||
- luacov-coveralls
|
||||
|
@@ -1,10 +1,11 @@
|
||||
#LuaDate v2.1
|
||||
# LuaDate v2.1
|
||||
|
||||
[](http://travis-ci.org/#!/Tieske/date/builds)
|
||||
[](https://travis-ci.org/Tieske/date)
|
||||
[](https://coveralls.io/github/Tieske/date?branch=master)
|
||||
|
||||
Lua Date and Time module for Lua 5.x.
|
||||
|
||||
##Features:
|
||||
## Features:
|
||||
|
||||
* Date and Time string parsing.
|
||||
* Time addition and subtraction.
|
||||
@@ -26,7 +27,7 @@ Documentation is available in the `doc` folder, or [online at Github](http://tie
|
||||
|
||||
Tests are located in the `spec` directory and can be run using [busted](http://olivinelabs.com/busted/).
|
||||
|
||||
##Changes:
|
||||
## Changes:
|
||||
|
||||
- v2.1.2 fix scientific notation [#9](https://github.com/Tieske/date/pull/9), now available for Lua 5.3
|
||||
- v2.1.1 fix for '>=' operator [#3](https://github.com/Tieske/date/pull/3), added test suite, added Travis CI, license MIT
|
||||
|
@@ -1,5 +1,5 @@
|
||||
package = "date"
|
||||
version = "2.1.2-1"
|
||||
version = "2.1.2-2"
|
||||
|
||||
description = {
|
||||
summary = "Date & Time module for Lua 5.x",
|
||||
@@ -24,7 +24,7 @@ source = {
|
||||
build = {
|
||||
type = "builtin",
|
||||
modules = {
|
||||
date = "date.lua"
|
||||
date = "src/date.lua"
|
||||
}
|
||||
}
|
||||
|
@@ -261,7 +261,7 @@ describe("Testing the 'date' module", function()
|
||||
end)
|
||||
|
||||
it("Tests 'getweekday()'", function()
|
||||
d = date(1970, 1, 1)
|
||||
local d = date(1970, 1, 1)
|
||||
assert(d:getweekday() == 5)
|
||||
end)
|
||||
|
||||
|
@@ -38,7 +38,7 @@
|
||||
local fmt = string.format
|
||||
local lwr = string.lower
|
||||
local rep = string.rep
|
||||
local len = string.len
|
||||
local len = string.len -- luacheck: ignore
|
||||
local sub = string.sub
|
||||
local gsub = string.gsub
|
||||
local gmatch = string.gmatch or string.gfind
|
||||
@@ -215,7 +215,8 @@
|
||||
local function getequivyear(y)
|
||||
assert(not yt)
|
||||
yt = {}
|
||||
local de, dw, dy = date_epoch:copy()
|
||||
local de = date_epoch:copy()
|
||||
local dw, dy
|
||||
for _ = 0, 3000 do
|
||||
de:setyear(de:getyear() + 1, 1, 1)
|
||||
dy = de:getyear()
|
||||
@@ -294,7 +295,7 @@
|
||||
if is then self.e, self.i = self.i, 1+ie; if f then f(unpack(self)) end return self end
|
||||
end
|
||||
local function date_parse(str)
|
||||
local y,m,d, h,r,s, z, w,u, j, e, k, x,c, dn,df;
|
||||
local y,m,d, h,r,s, z, w,u, j, e, x,c, dn,df
|
||||
local sw = newstrwalker(gsub(gsub(str, "(%b())", ""),"^(%s*)","")) -- remove comment, trim leading space
|
||||
--local function error_out() print(y,m,d,h,r,s) end
|
||||
local function error_dup(q) --[[error_out()]] error("duplicate value: " .. (q or "") .. sw:aimchr()) end
|
||||
@@ -317,7 +318,7 @@
|
||||
or sw:finish() or (sw"^%s*$" or sw"^%s*[Zz]%s*$" or sw("^%s-([%+%-])(%d%d):?(%d%d)%s*$",setzc) or sw("^%s*([%+%-])(%d%d)%s*$",setzn))
|
||||
) )
|
||||
then --print(y,m,d,h,r,s,z,w,u,j)
|
||||
sw:restart(); y,m,d,h,r,s,z,w,u,j = nil;
|
||||
sw:restart(); y,m,d,h,r,s,z,w,u,j = nil,nil,nil,nil,nil,nil,nil,nil,nil,nil
|
||||
repeat -- print(sw:aimchr())
|
||||
if sw("^[tT:]?%s*(%d%d?):",seth) then --print("$Time")
|
||||
_ = sw("^%s*(%d%d?)",setr) and sw("^%s*:%s*(%d%d?)",sets) and sw("^(%.%d+)",adds)
|
||||
@@ -336,9 +337,7 @@
|
||||
elseif inlist(x, sl_timezone, 2, sw) then
|
||||
c = fix(sw[0]) -- ignore gmt and utc
|
||||
if c ~= 0 then setz(c, x) end
|
||||
elseif inlist(x, sl_weekdays, 2, sw) then
|
||||
k = sw[0]
|
||||
else
|
||||
elseif not inlist(x, sl_weekdays, 2, sw) then
|
||||
sw:back()
|
||||
-- am pm bce ad ce bc
|
||||
if sw("^([bB])%s*(%.?)%s*[Cc]%s*(%2)%s*[Ee]%s*(%2)%s*") or sw("^([bB])%s*(%.?)%s*[Cc]%s*(%2)%s*") then
|
Reference in New Issue
Block a user