<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged conversion</title>
<link>https://ask.clojure.org/index.php/tag/conversion</link>
<description></description>
<item>
<title>How to filter with embedded conversion?</title>
<link>https://ask.clojure.org/index.php/10221/how-to-filter-with-embedded-conversion</link>
<description>&lt;p&gt;I have some data, which I'm able to do a simple filter on:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(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 (= &quot;non-fiction&quot; (:category %)) %) (get-books)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This works well.&lt;/p&gt;
&lt;p&gt;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:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(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 (&amp;gt;= (f/parse :date-time (:last_viewed_at %)) today) %) (get-posts)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I want all of the Maps which have a last_viewed_at DateTime &amp;gt;= to today.&lt;/p&gt;
&lt;p&gt;I'm trying to convert the String last_viewed_at to a DateTime and compare with today.&lt;/p&gt;
&lt;p&gt;It doesn't compile though:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Syntax error compiling def at (clojure_json_test/core.clj:46:1). Too&lt;br&gt;
many arguments to def&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Incidentially, I'm using:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(:require [clj-time.core :as t]
          [clj-time.format :as f]
          ;; ... )
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10221/how-to-filter-with-embedded-conversion</guid>
<pubDate>Sat, 20 Feb 2021 22:34:18 +0000</pubDate>
</item>
</channel>
</rss>