beginners

David Ko 2025-05-13T16:42:15.638319Z

Hi all I have a question about parsing date with Juxt tick library t/parse-date "01-Jan-84" (t/formatter "dd-MMM-yy" )) the output is 2084-01-01 instead of 1984-01-01 is there any to prevent it or I have to handle it myself, thank you

rolt 2025-05-14T09:24:16.378319Z

you need to handle reduced precision: on jvm:

(t/parse-date "01-Jan-84" (-> (java.time.format.DateTimeFormatterBuilder.) (.appendPattern "dd-MMM-") (.appendValueReduced java.time.temporal.ChronoField/YEAR 2 2 1900) (.toFormatter)))
you should be able to build the formatter with cljc.java-time.format.date-time-formatter-builder for a cross platform version

rolt 2025-05-14T09:27:13.338699Z

you may want to adjust the base year, pick the earliest year expected so that it also handles years in the early 2000 (e.g. 1980 will parse 92 as 1992 and 75 as 2075)

David Ko 2025-05-14T13:14:28.590169Z

Ok thanks I’ll give that a try I also found out Java can’t handle Sep, it has to be Sept for MMM

rolt 2025-05-14T14:01:50.647729Z

it works on my computer with Sep, and Sept doesn't, could be a locale issue ?

David Ko 2025-05-14T14:02:44.376219Z

Probably, but are you using cljc or tick?

rolt 2025-05-14T14:03:14.492899Z

it should be the same for parsing, I tried with tick

rolt 2025-05-14T14:09:27.857909Z

if you only handle dates in this particular format it might be easier to build your own parsing method at this point

👍 1
2025-05-13T16:49:56.214309Z

you may have a copy and paste error I get 2084-01-01 , basically because the data only specifies the last 2 digits of the year, the parser has to guess as to what century the year is in

David Ko 2025-05-13T16:52:10.469719Z

thanks for getting back, sorry i type it wrong, it was 2084 instead of 2089 let me change that, so I should handling the case myself then?

2025-05-13T16:54:20.744749Z

I am not very familiar with tick, but it seems like you would have to, what to do with underspecified data (yeas missing the century) doesn't seem like a 1 size fits all

👍 1
David Ko 2025-05-13T16:55:24.926359Z

i guess this is an edge case and Swift foundation took care of that, I’ll handle it myself then thanks!