Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stevedonovan/Penlight.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/manual/05-dates.md2
-rw-r--r--lua/pl/Date.lua18
-rw-r--r--lua/pl/types.lua18
-rw-r--r--lua/pl/utils.lua1
4 files changed, 20 insertions, 19 deletions
diff --git a/doc/manual/05-dates.md b/doc/manual/05-dates.md
index e3e98aa..c2431cf 100644
--- a/doc/manual/05-dates.md
+++ b/doc/manual/05-dates.md
@@ -2,7 +2,7 @@
<a id="date"></a>
-### Manipulating Dates
+### Creating and Displaying Dates
The `Date` class provides a simplified way to work with [date and
time](http://www.lua.org/pil/22.1.html) in Lua; it leans heavily on the functions
diff --git a/lua/pl/Date.lua b/lua/pl/Date.lua
index d1fbdf0..dd5bb5c 100644
--- a/lua/pl/Date.lua
+++ b/lua/pl/Date.lua
@@ -21,7 +21,7 @@ Date.Format = class()
-- * number - seconds since epoch (as returned by `os.time`). Resulting time is UTC
-- * `Date` - make a copy of this date
-- * table - table containing year, month, etc as for `os.time`. You may leave out year, month or day,
--- in which case current values will be used.
+-- in which case current values will be used.
-- * year (will be followed by month, day etc)
--
-- @param ... true if Universal Coordinated Time, or two to five numbers: month,day,hour,min,sec
@@ -263,7 +263,7 @@ end
--- long numerical ISO data format version of this date.
function Date:__tostring()
local t = os_date('%Y-%m-%dT%H:%M:%S',self.time)
- if self.utc then
+ if self.utc then
return t .. 'Z'
else
local offs = self:tzone()
@@ -292,6 +292,7 @@ function Date:__lt(other)
end
--- difference between Date objects.
+-- @function Date:__sub
Date.__sub = Date.diff
--- add a date and an interval.
@@ -368,12 +369,11 @@ local formats = {
-- Alternatively, if fmt is nil then this returns a flexible date parser
-- that tries various date/time schemes in turn:
--
--- # [ISO 8601](http://en.wikipedia.org/wiki/ISO_8601),
--- like `2010-05-10 12:35:23Z` or `2008-10-03T14:30+02`
--- # times like 15:30 or 8.05pm (assumed to be today's date)
--- # dates like 28/10/02 (European order!) or 5 Feb 2012
--- # month name like march or Mar (case-insensitive, first 3 letters);
--- here the day will be 1 and the year this current year
+-- * [ISO 8601](http://en.wikipedia.org/wiki/ISO_8601), like `2010-05-10 12:35:23Z` or `2008-10-03T14:30+02`
+-- * times like 15:30 or 8.05pm (assumed to be today's date)
+-- * dates like 28/10/02 (European order!) or 5 Feb 2012
+-- * month name like march or Mar (case-insensitive, first 3 letters); here the
+-- day will be 1 and the year this current year
--
-- A date in format 3 can be optionally followed by a time in format 2.
-- Please see test-date.lua in the tests folder for more examples.
@@ -621,7 +621,7 @@ local function parse_date_unsafe (s,US)
res.utc = true
-- we're in UTC, so let's go local...
res = res:toLocal()
- end
+ end
return res
end
diff --git a/lua/pl/types.lua b/lua/pl/types.lua
index ff5233d..c3249fc 100644
--- a/lua/pl/types.lua
+++ b/lua/pl/types.lua
@@ -76,7 +76,7 @@ end
--- can an object be iterated over with `ipairs`?
-- @param val any value.
-function types.is_iterable (idx,val)
+function types.is_iterable (val)
local mt = check_meta(val)
if mt == true then return true end
return not(mt and mt.__pairs)
@@ -84,7 +84,7 @@ end
--- can an object accept new key/pair values?
-- @param val any value.
-function types.is_writeable (idx,val)
+function types.is_writeable (val)
local mt = check_meta(val)
if mt == true then return true end
return not(mt and mt.__newindex)
@@ -112,15 +112,17 @@ local true_types = {
}
--- Convert to a boolean value.
-- True values are:
--- * boolean: true (doesn't make sense to pass a boolean to a to boolean function though...).
--- * string: yes, y, true, t, 1 or additional strings specified by true_strs.
+--
+-- * boolean: true.
+-- * string: 'yes', 'y', 'true', 't', '1' or additional strings specified by `true_strs`.
-- * number: Any non-zero value.
--- * table: Is not empty and check_objs is true.
--- * object: Is not nil and check_objs is true.
+-- * table: Is not empty and `check_objs` is true.
+-- * object: Is not `nil` and `check_objs` is true.
+--
-- @param o The object to evaluate.
--- @param true_strs optional Additional strings that when matched should evaluate to true. Comparison is case insensitive.
+-- @param[opt] true_strs optional Additional strings that when matched should evaluate to true. Comparison is case insensitive.
-- This should be a List of strings. E.g. "ja" to support German.
--- @param optional check_objs True if objects should be evaluated. Default is to evaluate objects as true if not nil
+-- @param[opt] check_objs True if objects should be evaluated. Default is to evaluate objects as true if not nil
-- or if it is a table and it is not empty.
-- @return true if the input evaluates to true, otherwise false.
function types.to_bool(o, true_strs, check_objs)
diff --git a/lua/pl/utils.lua b/lua/pl/utils.lua
index 4e96bf2..90ac075 100644
--- a/lua/pl/utils.lua
+++ b/lua/pl/utils.lua
@@ -319,7 +319,6 @@ local ops
-- @param msg optional error message
-- @return a callable
-- @raise if idx is not a number or if f is not callable
--- @see utils.is_callable
function utils.function_arg (idx,f,msg)
utils.assert_arg(1,idx,'number')
local tp = type(f)