aboutsummaryrefslogtreecommitdiffstats
path: root/util/dataforms.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-10-26 15:17:49 +0200
committerKim Alvefur <zash@zash.se>2021-10-26 15:17:49 +0200
commitf956b07ca0480883c7a050d190b8bc6b1a509d85 (patch)
tree7bffc34930b1ba976bd0411ffab1bf56a409f562 /util/dataforms.lua
parentfc677f515fd0fe5c45d54e51f5646f37e204929a (diff)
downloadprosody-f956b07ca0480883c7a050d190b8bc6b1a509d85.tar.gz
prosody-f956b07ca0480883c7a050d190b8bc6b1a509d85.zip
util.dataforms: Turn number values into timestamps for datetime fields
Makes it symmetric with parsing.
Diffstat (limited to 'util/dataforms.lua')
-rw-r--r--util/dataforms.lua4
1 files changed, 3 insertions, 1 deletions
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);