mirror of
https://github.com/TangentFoxy/lua-date.git
synced 2025-07-28 11:02:17 +00:00
Upload version 2.0
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
package = "date"
|
||||
version = "1.0-1"
|
||||
source = {
|
||||
url = "http://luaforunix.luaforge.net/packages/date-1.0-1.tar.gz",
|
||||
}
|
||||
description = {
|
||||
summary = "Lua Date and Time module for Lua 5.1",
|
||||
detailed = [[
|
||||
Date and Time string parsing; Time addition and subtraction;
|
||||
Time span calculation; Supports ISO 8601 Dates.
|
||||
]],
|
||||
license = "MIT/X11",
|
||||
homepage = "http://luaforge.net/projects/date/",
|
||||
maintainer = "Steve Donovan <steve.j.donovan@gmail.com>",
|
||||
}
|
||||
dependencies = {
|
||||
}
|
||||
build = {
|
||||
type = "none",
|
||||
copy_directories = {'doc','samples'},
|
||||
install = {
|
||||
lua = {
|
||||
date = "date.lua"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
29
date-2.0.1-1.rockspec
Normal file
29
date-2.0.1-1.rockspec
Normal file
@@ -0,0 +1,29 @@
|
||||
package = "date"
|
||||
version = "2.0.1-1"
|
||||
|
||||
description = {
|
||||
summary = "Date & Time module for Lua 5.x",
|
||||
detailed = [[
|
||||
Pure Lua Date & Time module for Lua 5.x featuring date and Time string
|
||||
parsing, time addition & subtraction, time span calculation, support for
|
||||
ISO 8601 Dates, local time support, strftime-like formatting.
|
||||
]],
|
||||
license = "Public Domain",
|
||||
homepage = "http://luaforge.net/projects/date/",
|
||||
}
|
||||
|
||||
dependencies = {
|
||||
"lua ~> 5.1"
|
||||
}
|
||||
|
||||
source = {
|
||||
url = "http://luaforge.net/frs/download.php/1708/date.zip",
|
||||
dir = ".",
|
||||
}
|
||||
|
||||
build = {
|
||||
type = "builtin",
|
||||
modules = {
|
||||
date = "date.lua"
|
||||
}
|
||||
}
|
6
date.lua
6
date.lua
@@ -403,7 +403,6 @@
|
||||
end
|
||||
--#end -- not DATE_OBJECT_AFX
|
||||
local function date_from(...)
|
||||
local arg = {...}
|
||||
local y, m, d = fix(arg[1]), getmontharg(arg[2]), fix(arg[3])
|
||||
local h, r, s, t = tonumber(arg[4] or 0), tonumber(arg[5] or 0), tonumber(arg[6] or 0), tonumber(arg[7] or 0)
|
||||
if y and m and d and h and r and s and t then
|
||||
@@ -701,9 +700,8 @@
|
||||
end
|
||||
|
||||
function date:__call(...)
|
||||
local arg = {...}
|
||||
local n = #arg
|
||||
if n > 1 then return (date_from(...))
|
||||
local n = arg.n
|
||||
if n > 1 then return (date_from(unpack(arg)))
|
||||
elseif n == 0 then return (date_getdobj(false))
|
||||
else local o, r = date_getdobj(arg[1]); return r and o:copy() or o end
|
||||
end
|
||||
|
BIN
doc/date.doc.chm
Normal file
BIN
doc/date.doc.chm
Normal file
Binary file not shown.
@@ -1,23 +0,0 @@
|
||||
require 'date'
|
||||
|
||||
d1 = date('July 4 2009')
|
||||
assert(d1:getmonth() == 7)
|
||||
d2 = d1:copy()
|
||||
d2:adddays(2)
|
||||
diff = d2 - d1
|
||||
assert(diff:spandays() == 2)
|
||||
assert(diff:spanhours() == 48)
|
||||
|
||||
assert(date 'July 4 2009' == date '2009-07-04')
|
||||
|
||||
a = date(1970, 1, 1)
|
||||
y, m, d = a:getdate()
|
||||
assert(y == 1970 and m == 1 and d == 1)
|
||||
|
||||
d = date(1966, 'sep', 6)
|
||||
assert(d:getday() == 6)
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user