I know you said clj-time solved this for you, but here's another way to
handle it which avoids using a macro (using a map of keywords to
java.util.Calendar weekday enums for convenience and to be more
Clojure-esque, but it isn't necessary):
user=> (def weekdays {:mon Calendar/MONDAY :tues Calendar/TUESDAY :wed
Calendar/WEDNESDAY :thurs Calendar/THURSDAY :fri Calendar/FRIDAY :sat
Calendar/SATURDAY :sun Calendar/SUNDAY})
#'user/weekdays
user=> (defn is-day-of-week? [day-enum] (= Calendar/DAY_OF_WEEK
(day-enum weekdays)))
#'user/is-day-of-week?
user=> (is-day-of-week? :sat)
false
user=> (is-day-of-week? :wed)
true
user=>
You don't need to use all the Java interop syntax you're using, you can
refer to and compare these static fields directly. In the end these are
simply Integer comparisons.
DD
>>
https://github.com/clj-time/__clj-time
>> <
https://github.com/clj-time/clj-time>
>>
>> (ns time.core
>> (:require [clj-time.core :as time]
>> [clj-time.local :as local]
>> [clj-time.predicates :as p]))
>>
>> (p/monday? (time/now)) ;; false
>> (p/tuesday? (time/now)) ;; false
>> (p/wednesday? (time/now)) ;; true (for me in California since
>> (time/now) is UTC)
>>
>> (p/monday? (local/local-now)) ;; false
>> (p/tuesday? (local/local-now)) ;; true (for me)
>> (p/wednesday? (local/local-now)) ;; false (not yet in California)
>>
>> Sean
>>
>> On Tue, Aug 13, 2013 at 3:14 PM, Daniel Meneses B�ez
>> <
dap...@gmail.com> wrote:
>> > Hi :)
>> >
>> > I really want to know if there is a way to do this:
>> >
>> > (ns ...
>> > (:import [java.util Calendar]))
>> >
>> > (defsomething ;; if it is possible using a macro I'm ok with
>> that
>> > calendar-member
>> > [member]
>> > (symbol (str "Calendar/" member)))
>> >
>> > what I want to know if an instance of Calendar "isMonday",
>> "isFriday"
>> > "isSunday" etc...
>> >
>> > so I was thinking to write something like
>> >
>> > (defn- isss [day instant]
>> > (= (.get instant Calendar/DATE) (calendar-member day)))
>> >
>> > and then use it like (def is-friday (partial isss 'FRIDAY)) ;;
>> >
>> > am I being to crazy?
>> >
>> > btw I'm really loving the language.
>> >
>> >
>> >
>> > --
>> > Daniel Meneses B�ez
>> >
>> > --
>> > --
>> > You received this message because you are subscribed to the
>> Google
>> > Groups "Clojure" group.
>> > To post to this group, send email to
clo...@googlegroups.com
>> > Note that posts from new members are moderated - please be
>> patient with your
>> > first post.
>> > To unsubscribe from this group, send email to
>> > clojure+u...@__
googlegroups.com
>> > For more options, visit this group at
>> >
http://groups.google.com/__group/clojure?hl=en
>> <
http://groups.google.com/group/clojure?hl=en>
>> > ---
>> > You received this message because you are subscribed to the
>> Google Groups
>> > "Clojure" group.
>> > To unsubscribe from this group and stop receiving emails
>> from it, send an
>> > email to clojure+u...@__
googlegroups.com.
>> > For more options, visit
>>
https://groups.google.com/__groups/opt_out
>> <
https://groups.google.com/groups/opt_out>.
>> >
>> >
>>
>>
>>
>> --
>> Sean A Corfield -- (904) 302-SEAN
>> An Architect's View --
http://corfield.org/
>> World Singles, LLC. --
http://worldsingles.com/
>>
>> "Perfection is the enemy of the good."
>> -- Gustave Flaubert, French realist novelist (1821-1880)
>>
>> --
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to
clo...@googlegroups.com
>> <mailto:
clo...@googlegroups.com>
>> Note that posts from new members are moderated - please be patient
>> with your first post.
>> To unsubscribe from this group, send email to
>>
clojure+u...@googlegroups.com
>> <mailto:
clojure+u...@googlegroups.com>
>> <mailto:
clojure+u...@googlegroups.com>.
> <mailto:
clo...@googlegroups.com>
> Note that posts from new members are moderated - please be patient
> with your first post.
> To unsubscribe from this group, send email to
>
clojure+u...@googlegroups.com
> <mailto:
clojure%2Bunsu...@googlegroups.com>
> <mailto:
clojure%2Bunsu...@googlegroups.com>.
> Daniel Meneses B�ez