Creating global javascript objects (like Date) in Clojurescript

1,502 views
Skip to first unread message

Conrad

unread,
Aug 12, 2011, 5:19:07 PM8/12/11
to Clojure
Sorry if this has an obvious answer, but there is still only limited
documentation on clojurescript native interop on the net right now,
and none of the code I've seen of runs into this use case...

How do I create a javascript Date object in Clojurescript? I've tried:

(Date.)
(window/Date.)
(.now Date)

I've run out of ideas for what the correct incantation is- Can someone
give me a pointer? Thanks!

-Conrad Barski

Michael Wood

unread,
Aug 12, 2011, 6:15:43 PM8/12/11
to clo...@googlegroups.com

After some trial and error, I found this:

ClojureScript:cljs.user> (new js/Date)
#<Sat Aug 13 2011 00:14:54 GMT+0200 (SAST)>
ClojureScript:cljs.user> (js/Date.)
#<Sat Aug 13 2011 00:15:01 GMT+0200 (SAST)>

--
Michael Wood <esio...@gmail.com>

Conrad

unread,
Aug 12, 2011, 8:34:11 PM8/12/11
to Clojure
Ah! I didn't know about a js namespace- Thanks for figuring that out,
Michael!
> Michael Wood <esiot...@gmail.com>
Reply all
Reply to author
Forward
0 new messages