Follow

Todo: write a script to convert from a given JDN to verbose date. So `babashka-date 2024030` => `Tue 2024.01.30`. Apparently GNU bash `date` can OUTPUT formats that it cannot intake.

@borkdude sounds like it might turn out to be a one-liner then!

@borkdude Well, it isn't one line, but it is basically one function. It took some research into how and what libraries to use, but here it is: gitlab.com/toryanderson/bb-jul

@worldsendless It's recommended to use java.time (newer thread-safe API) over java.text (single threaded, kinda deprecated)

@borkdude you mean the `java.text.SimpleDateFormat` ? I searched all over the internet and that is the only thing I could find to get the function right

@worldsendless

```
(def from-fmt (java.time.format.DateTimeFormatter/ofPattern "yyyyMMdd"))
(def date (java.time.LocalDate/parse "20101022" from-fmt))
(def to-fmt (java.time.format.DateTimeFormatter/ofPattern "E yyyy.MM.dd"))
(println (.format to-fmt date))
```

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.