Major restructuring to get automatic decoding/encoding
[pycalendar.git] / pycalendar / dtype / numeric.py
diff --git a/pycalendar/dtype/numeric.py b/pycalendar/dtype/numeric.py
new file mode 100644 (file)
index 0000000..4574098
--- /dev/null
@@ -0,0 +1,32 @@
+# Copyright
+
+"""Functions for processing numeric types
+
+As defined in :RFC:`5545`, sections 3.3.7 (Float) and 3.3.8 (Integer).
+"""
+
+from . import base as _base
+
+
+class Integer (_base.DataType):
+    name = 'INTEGER'
+
+    @classmethod
+    def decode(cls, property, value):
+        return int(value)
+
+    @classmethod
+    def encode(cls, property, value):
+        return '{:d}'.format(value)
+
+
+class Float (_base.DataType):
+    name = 'FLOAT'
+
+    @classmethod
+    def decode(cls, property, value):
+        return int(value)
+
+    @classmethod
+    def encode(cls, property, value):
+        return '{:d}'.format(value)