aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--spec/util_dataforms_spec.lua2
-rw-r--r--util/dataforms.lua4
2 files changed, 4 insertions, 2 deletions
diff --git a/spec/util_dataforms_spec.lua b/spec/util_dataforms_spec.lua
index a76a9565..16fffb42 100644
--- a/spec/util_dataforms_spec.lua
+++ b/spec/util_dataforms_spec.lua
@@ -461,7 +461,7 @@ describe("util.dataforms", function ()
local f = dataforms.new { { name = "when"; type = "text-single"; datatype = "xs:dateTime" } } -- luacheck: ignore 431
it("works", function ()
- local x = f:form({ when = "2008-08-22T21:09:00Z" });
+ local x = f:form({ when = 1219439340 });
assert.equal("2008-08-22T21:09:00Z", x:find("field/value#"))
local d, e = f:data(x);
assert.is_nil(e);
diff --git a/util/dataforms.lua b/util/dataforms.lua
index 7bb3cff9..6bd44bdc 100644
--- a/util/dataforms.lua
+++ b/util/dataforms.lua
@@ -103,7 +103,9 @@ function form_t.form(layout, data, formtype)
if value ~= nil then
if type(value) == "number" then
- if field_type == "boolean" then
+ if field.datatype == "xs:dateTime" then
+ value = datetime.datetime(value);
+ elseif field_type == "boolean" then
value = value ~= 0;
else
value = ("%g"):format(value);