webmcp
annotate framework/env/parse/currency.lua @ 11:d76a8857ba62
Added ui.partial and other functions, which allow partial content replacement using XMLHttpRequests; Image support for ui.link
Also includes following changes:
- Fix for rocketcgi library to accept POST data content-types, which contain additional charset information.
- Support arrays passed as params to encode.url (only for keys ending with "[]")
- Version information changed to "1.0.7"
Documentation for added functions is not yet complete.
Also includes following changes:
- Fix for rocketcgi library to accept POST data content-types, which contain additional charset information.
- Support arrays passed as params to encode.url (only for keys ending with "[]")
- Version information changed to "1.0.7"
Documentation for added functions is not yet complete.
author | jbe/bsw |
---|---|
date | Fri Feb 12 18:40:22 2010 +0100 (2010-02-12) |
parents | 9fdfb27f8e67 |
children |
rev | line source |
---|---|
jbe/bsw@0 | 1 local function extract_numbers(str) |
jbe/bsw@0 | 2 local result = {} |
jbe/bsw@0 | 3 for char in string.gmatch(str, "[0-9]") do |
jbe/bsw@0 | 4 result[#result+1] = char |
jbe/bsw@0 | 5 end |
jbe/bsw@0 | 6 return table.concat(result) |
jbe/bsw@0 | 7 end |
jbe/bsw@0 | 8 |
jbe/bsw@0 | 9 function parse.currency(str, dest_type, options) |
jbe/bsw@0 | 10 local str = parse._pre_fold(str) |
jbe/bsw@0 | 11 local dest_type = dest_type or atom.number |
jbe/bsw@0 | 12 local options = options or {} |
jbe/bsw@0 | 13 local currency_decimal_point = locale.get("currency_decimal_point") |
jbe/bsw@0 | 14 local decimal_point = locale.get("decimal_point") or "." |
jbe/bsw@0 | 15 local pos1, pos2 |
jbe/bsw@0 | 16 if currency_decimal_point then |
jbe/bsw@0 | 17 pos1, pos2 = string.find(str, currency_decimal_point, 1, true) |
jbe/bsw@0 | 18 end |
jbe/bsw@0 | 19 if not pos1 then |
jbe/bsw@0 | 20 pos1, pos2 = string.find(str, decimal_point, 1, true) |
jbe/bsw@0 | 21 end |
jbe/bsw@0 | 22 if pos1 then |
jbe/bsw@0 | 23 local p1 = extract_numbers(string.sub(str, 1, pos1 - 1)) |
jbe/bsw@0 | 24 local p2 = extract_numbers(string.sub(str, pos2 + 1, #str)) |
jbe/bsw@0 | 25 return parse.decimal(p1 .. decimal_point .. p2, dest_type, options) |
jbe/bsw@0 | 26 else |
jbe/bsw@0 | 27 return parse.decimal(extract_numbers(str), dest_type, options) |
jbe/bsw@0 | 28 end |
jbe/bsw@0 | 29 end |