diff options
author | Sebastian Reichel <sre@ring0.de> | 2012-11-04 00:09:04 +0100 |
---|---|---|
committer | Sebastian Reichel <sre@ring0.de> | 2012-11-04 00:09:04 +0100 |
commit | 7857ca5c733d8516ab636a5be4f7f6b61f8cf28e (patch) | |
tree | 21352ea962d806d2894181005611f140b2409963 /src/price.vapi | |
parent | 0c7e43956cd13730dd61d3eea4c6eb420115f057 (diff) | |
download | serial-barcode-scanner-7857ca5c733d8516ab636a5be4f7f6b61f8cf28e.tar.bz2 |
support € values with . notation in web forms
Diffstat (limited to 'src/price.vapi')
-rw-r--r-- | src/price.vapi | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/price.vapi b/src/price.vapi index b60e2a6..ab7abee 100644 --- a/src/price.vapi +++ b/src/price.vapi @@ -6,4 +6,13 @@ public struct Price : int { public new string to_string() { return "%d.%02d".printf(this / 100, this % 100); } + + public static Price parse(string data) { + if("." in data) { + var parts = data.split("."); + return int.parse(parts[0])*100 + int.parse(parts[1]); + } else { + return int.parse(data); + } + } } |