summaryrefslogtreecommitdiff
path: root/src/utils.clj
diff options
context:
space:
mode:
authorScott Ostler <scottbot9000@gmail.com>2010-06-18 22:47:11 -0400
committerScott Ostler <scottbot9000@gmail.com>2010-06-18 22:47:11 -0400
commitc937f0335938106de28b7a001ac094ffafbf62d3 (patch)
tree2371b4021d782490dbe7a15eee5150351e068abc /src/utils.clj
parent92f46acde02afacd7ea8de29442dd68ebe71a37b (diff)
Added comma formats
Diffstat (limited to 'src/utils.clj')
-rwxr-xr-xsrc/utils.clj11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/utils.clj b/src/utils.clj
index 779bb7b..8bd8291 100755
--- a/src/utils.clj
+++ b/src/utils.clj
@@ -108,6 +108,17 @@
;; Formatters
+(defn- comma-helper [s]
+ (let [f (take 3 s)
+ r (drop 3 s)]
+ (if (= (count r) 0)
+ f
+ (append (comma-helper r) [\,] (reverse f)))))
+
+(defn comma-format [i]
+ (apply str
+ (reverse (comma-helper (reverse (str i))))))
+
(def yyyy-mm-dd-formatter (new SimpleDateFormat "yyyy-MM-dd"))
(defn format-yyyy-mm-dd [d]