From 851127ecd70c9c7e5e5c13565d26b908a020b69e Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 25 Oct 2021 21:45:46 +0200 Subject: util.dataforms: Add support for datetime field types via XEP-0122 --- spec/util_dataforms_spec.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'spec') diff --git a/spec/util_dataforms_spec.lua b/spec/util_dataforms_spec.lua index d2d1264a..f796b30d 100644 --- a/spec/util_dataforms_spec.lua +++ b/spec/util_dataforms_spec.lua @@ -446,6 +446,20 @@ describe("util.dataforms", function () assert.table(e); assert.string(e.number); end); + + describe("datetime", 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" }); + assert.equal("2008-08-22T21:09:00Z", x:find("field/value#")) + local d, e = f:data(x); + assert.is_nil(e); + assert.same({ when = 1219439340 }, d); + end); + + end) + end); describe("media element", function () it("produced media element correctly", function () -- cgit v1.2.3