I have some data, which I'm able to do a simple filter on:
(defn get-posts-body
[]
(:body @(client/get posts-url api-options)))
(defn get-books
[]
(parse-string (get-books-body) true))
(defn get-non-fiction-books
[]
(filter #(if (= "non-fiction" (:category %)) %) (get-books)))
This works well.
I have another data source, posts, which I want to convert a field to a DateTime type and do a comparison on as well. Though it's not working:
(defonce today (.withTimeAtStartOfDay (t/now)))
(defn get-posts-body
[]
(:body @(client/get posts-url api-options)))
(defn get-posts
[]
(parse-string (get-posts-body) true))
(def get-posts-viewed-today
[]
(filter #(if (>= (f/parse :date-time (:last_viewed_at %)) today) %) (get-posts)))
I want all of the Maps which have a last_viewed_at DateTime >= to today.
I'm trying to convert the String last_viewed_at to a DateTime and compare with today.
It doesn't compile though:
Syntax error compiling def at (clojure_json_test/core.clj:46:1). Too
many arguments to def
Incidentially, I'm using:
(:require [clj-time.core :as t]
[clj-time.format :as f]
;; ... )