Software /
code /
prosody
Comparison
util/dataforms.lua @ 11880:d30c81b875f2
util.dataforms: Ensure larger integers are serialized as such
Assumes that most number fields are integers, as most numeric types
listed in XEP-0122 are, as are all such fields in Prosody as of this.
Otherwise %g produces something like 1.1259e+15
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 28 Oct 2021 13:00:24 +0200 |
parent | 11878:bf6706057283 |
child | 11881:2138fc13d53a |
comparison
equal
deleted
inserted
replaced
11879:b8b889ba8d27 | 11880:d30c81b875f2 |
---|---|
105 if type(value) == "number" then | 105 if type(value) == "number" then |
106 if field.datatype == "xs:dateTime" then | 106 if field.datatype == "xs:dateTime" then |
107 value = datetime.datetime(value); | 107 value = datetime.datetime(value); |
108 elseif field_type == "boolean" then | 108 elseif field_type == "boolean" then |
109 value = value ~= 0; | 109 value = value ~= 0; |
110 elseif field.datatype == "xs:double" or field.datatype == "xs:decimal" then | |
111 value = ("%f"):format(value); | |
110 else | 112 else |
111 value = ("%g"):format(value); | 113 value = ("%d"):format(value); |
112 end | 114 end |
113 end | 115 end |
114 -- Add value, depending on type | 116 -- Add value, depending on type |
115 if field_type == "hidden" then | 117 if field_type == "hidden" then |
116 if type(value) == "table" then | 118 if type(value) == "table" then |