Library
FD1 Reply Format Options
FD1 allows you to specify the reply format for dates and money. The system has its own defaults but you can override them on the server.
The formats can be overridden on a per request basis using the "rf" parameter, or at session login time. The value used cascades from request, to session, to system default.
"rf" is an object providing the formats you want.
rf: {
money: "currency value",
date: "yyyy-mmm-dd hh:min:sec"
}
Dates and Times
Note, FD1 does not allow dates using either MM/DD/YYYY or DD/MM/YYYY formats. eg. 03/02/2020. While these are great formats for users, they are locale specific and incredibly hard for servers to understand the exact date. The format 3-Feb-2020 is acceptable as it is unambiguous.
Within FD1 protocol, all date fields are clearly documented if they are local time or UTC. Some date formats want the timezone information as well for local time, but this isnt always available.
| format | Description | Timezone | Example 2-mar-2026 17:23:55 |
| sqlite | YYYY-mm-DD HH:MM:SS with a single space character seperating date and time components. This is the default format | No | date: "2026-03-02 17:23:55" |
| ISO8601-T | ISO Standard 8601 with a "T" seperating date and time components | Yes | date: "2026-03-02T17:23:55" |
| ISO8601-space ISO8601-S |
ISO Standard 8601 with a single space character seperating date and time components | Yes | date: "2026-03-02 17:23:55" |
| short | Encode dates using a common short form, months are encoded using an abbreviated month name. | No | date: "2-mar-2026 17:23:55" |
| rve | Represent as a floating point number with the structure YYYYMMDD.HHmmSS[ccc] This is a non precise format, but is suitable for holding date/time to the second. This format does not include timezone information. | No | date: 20260302.172355" |
Money
Monetary amounts should not be stored and processed using floating point datatypes. This also means you should not use Number format in Javascript. The issue is that floating point datatypes cannot hold precise decimals (search for 0.1 + 0.2 not equal 0.3 to learn more) This can create some real and visible issues around pricing, totals and math.
However, floating point numbers are very easy to work with in code, and sometimes these minor differences are not important.
Rounding issues crop up way more often than you might expect. A 3items for $10 has a price of 3.33333333 per item. Rounded to 2dp thats 3.33. But 3x 3.33 is 9.99.
| format | Description | Example 17.23 |
| real float double |
amt: 17.23 | |
| string | Values represented as a simple string with a dot separating dollars and cents. This is the default | amt: "17.23" |
| currency value | amt: "XXX 17.23" | |
| scale2 | Return an integer with the amount scaled by 100, or 2 decimal places | amt: 1723 |
| scale4 | Return an integer with the amount scaled by 10000, or 4 decimal places | amt: 172300 |
Each of the above types can have prefix "object" or "array", in which case the amount is written to an "amt" field or the first array element, and the currency is in "cur" or second array field. The option "currency value" cannot use these prefixes.
| rf: money value | Example 17.23 for "saletotal" |
| money: "string" | saletotal: "17.23" |
| money: "object string" |
saletotal: {
amt: "17.23",
cur: "AUD"
}
|
| money: "array real" | saletotal: [17.23, "AUD"] |
Javascript. For simple reports either the real or string formats are generally acceptable. If performing math, especially using salesbuilder functions, then use caution. For precise handling consider using a library such as BigNumber.js and the string format.