MastodonC / kixi.hecuba

Eclipse Public License 1.0
36 stars 5 forks source link

Most uses of read-string in hecuba should be replaced. #649

Open sw1nn opened 8 years ago

sw1nn commented 8 years ago

If we are reading user data, in particular numbers, we cannot use read-string because it has features that users of the api do not expect.

e.g. measurements where the value is '09'

(read-string "09")
NumberFormatException Invalid number: 09  clojure.lang.LispReader.readNumber (LispReader.java:256)         

There's an example in kixi.hecuba.time/in-interval? which parses dates with read-string

This won't work if the start or the end time is HH:08 or HH:09

My recommendation is that numbers are always parsed with

Integer/parseInt or Long/parseLong or Float/parseFloat or Double/parseDouble

dates and times should always be parsed with a date/time library (clj-time), 'cos the rules are so arcane that no reasonable person can be expected to know them.

sw1nn commented 8 years ago

https://gist.github.com/Eleonore9/f747540d919f6f1a8fde

Eleonore9 commented 8 years ago

Sorry, I added a new file to the gist. This exception is in: https://gist.github.com/Eleonore9/f747540d919f6f1a8fde#file-log-dse00-18092015-rollups