Mercurial > prosody-hg
comparison util/dataforms.lua @ 11878:bf6706057283
util.dataforms: Turn number values into timestamps for datetime fields
Makes it symmetric with parsing.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 26 Oct 2021 15:17:49 +0200 |
| parents | 593b141ba01c |
| children | d30c81b875f2 |
comparison
equal
deleted
inserted
replaced
| 11877:593b141ba01c | 11878:bf6706057283 |
|---|---|
| 101 end | 101 end |
| 102 end | 102 end |
| 103 | 103 |
| 104 if value ~= nil then | 104 if value ~= nil then |
| 105 if type(value) == "number" then | 105 if type(value) == "number" then |
| 106 if field_type == "boolean" then | 106 if field.datatype == "xs:dateTime" then |
| 107 value = datetime.datetime(value); | |
| 108 elseif field_type == "boolean" then | |
| 107 value = value ~= 0; | 109 value = value ~= 0; |
| 108 else | 110 else |
| 109 value = ("%g"):format(value); | 111 value = ("%g"):format(value); |
| 110 end | 112 end |
| 111 end | 113 end |
