Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unparse fails with [org.clojure/clojurescript "1.7.122"] due to clojure.string/replace #43

Closed
hipitihop opened this issue Aug 31, 2015 · 9 comments

Comments

@hipitihop
Copy link

Tested with com.andrewmcveigh/cljs-time "0.3.11" and clojurescript 1.7.58 and earlier and the following test passes, but fails in 1.7.122 due to clojure.string/replace changes.

(deftest default-basic-time
  (testing "Confirm base cljs-time :basic-time uses zero time, seconds & milliseconds"
    (let [formatter-no-time   (datef/formatters :basic-date)
          formatter-with-time (datef/formatters :basic-date-time)
          iso8601             "20150408"
          from-str            (datef/parse formatter-no-time iso8601)        ; instantiate UTC from string without time
          from-date           (datef/unparse formatter-with-time from-str)]  ; convert back to UTC string with time
      (is (instance? js/goog.date.UtcDateTime from-str))
      (is (= "20150408T000000.000Z" from-date) "We expect UTC time including milliseconds to be zero."))))
@malchmih
Copy link

+1

1 similar comment
@levand
Copy link

levand commented Sep 1, 2015

+1

@andrewmcveigh
Copy link
Owner

Thanks for the report.

This should be "fixed" in ccb19d0 by using the old string/replace definition, until I merge in some bigger changes that shouldn't require string/replace anymore.

Released as 0.3.12.

@malchmih
Copy link

malchmih commented Sep 2, 2015

@andrewmcveigh Works for me, thank you!

@danielcompton
Copy link
Collaborator

I didn't fully understand the root cause of this issue. Is it a bug in cljs that should be reported?

@andrewmcveigh
Copy link
Owner

@danielcompton Not sure if it's bug or not, but it's a change in behaviour to align with jvm clojure[1].

I don't think this case is tested, so maybe it is a bug. I guess I'd need to better understand the motivation of the change to know if it's intentionally breaking this behaviour.

[1] clojure/clojurescript@3e14690

@adwelly
Copy link

adwelly commented Oct 9, 2015

I think I may have encountered something related to this:

Using [org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.122"]
[com.andrewmcveigh/cljs-time "0.3.14"]

using lein figwheel I can do the following in the repl

......(fighwheel launches)
Prompt will show when figwheel connects to your application
To quit, type: :cljs/quit
cljs.user=> (ns cljs.user (:require [cljs-time.format :as f][cljs-time.coerce :as c]))
;; This loads cljs-time format and cljs-time coerce, I can't seem to get (use ...) working.
cljs.user=> (def datefmt (f/formatter "dd-MM-yyyy")) ;; I create a custom formatter
#'cljs.user/datefmt
cljs.user=> (def atime (c/from-long 1400000000)) ;; and a datetime - sometime in 1970
#'cljs.user/atime
cljs.user=> atime
#object[Object 19700117T045320]
cljs.user=> (f/unparse datefmt atime)
#object[TypeError TypeError: Cannot read property 'call' of null] ;; <- something wrong
cljs.user=> (f/show-formatters)
#object[TypeError TypeError: Cannot read property 'call' of null] ;; <- show-formatters uses unparse too
cljs.user=>

I'm always open to the possibility that I'm doing something catastrophically daft, but this code was working with an earlier version of clojurescript a few months back.

@andrewmcveigh
Copy link
Owner

It's probably related to #41 & bhauman/lein-figwheel#210 rather than this issue.

What version of figwheel are you on?

@adwelly
Copy link

adwelly commented Oct 9, 2015

Just looked - figwheel 0.4.0, I see there's a figwheel 0.4.1 now. I shall give it a go and report back

Update - Yes, as you said, figwheel 0.4.0 is the root cause, the upgrade to 0.4.1 seems to have fixed the issue completely. Thanks very much for the prompt reply; it's very much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants