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

Switch the build tool to shadow-cljs and bugfix #143

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ out/
clojurescript/
doc/
bin/
.calva/
.clj-kondo/
.lsp/
.shadow-cljs/
node_modules/
yarn.lock
39 changes: 6 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,11 @@ object return a copy, leaving the referenced date object alone. In the
future, immutable date objects will be preferred.

## Artifacts

`cljs-time` artifacts are [released to Clojars](https://clojars.org/com.andrewmcveigh/cljs-time).

If you are using Maven, add the following repository definition to your `pom.xml`:

``` xml
<repository>
<id>clojars.org</id>
<url>http://clojars.org/repo</url>
</repository>
```

### The Most Recent Release

With Leiningen:

Update your **deps.edn** to use:
``` clj
;; Stable
[com.andrewmcveigh/cljs-time "0.5.2"]
{:deps
{logseq/cljs-time
{:git/url "https://github.com/logseq/cljs-time" :sha "xxxx"}}}
```

## Bugs and Enhancements
Expand Down Expand Up @@ -277,24 +263,11 @@ And by the magic of protocols you can pass in an isoformat string and get the un

Running the tests:

$ boot test-all

OR

$ boot auto-test
$ shadow-cljs compile test

### Getting a REPL

$ boot repl # (or jack-in from cider/etc)

``` clojure
boot.user> (node-repl)
clojurescript node.js repl server listening on 56950
to quit, type: :cljs/quit
nil
cljs.user> (+ 1 1)
2
```
$ shadow-cljs watch app

## Documentation

Expand Down
1 change: 0 additions & 1 deletion boot.properties

This file was deleted.

126 changes: 0 additions & 126 deletions build.boot

This file was deleted.

17 changes: 0 additions & 17 deletions compile/cljs_time/dce_compile_test.cljs

This file was deleted.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"devDependencies": {
"shadow-cljs": "^2.11.15"
}
}
13 changes: 9 additions & 4 deletions perf/parse_perf_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,13 @@
v2-avg (run-perf v2)]
{:v1-avg-ms v1-avg :v2-avg-ms v2-avg}))

(defn run
([] (run old-version new-version))
([v1 v2]
(println
"Average runs:"
(pr-str (compare v1 v2)))))

(comment

(compare old-version new-version)

)

(compare old-version new-version))
21 changes: 21 additions & 0 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{:source-paths
["src" "test" "perf"]

:dependencies
[]

:repositories
{"central" {:url "https://maven.aliyun.com/nexus/content/groups/public/"}
"clojars" {:url "https://mirrors.ustc.edu.cn/clojars/"}}

:builds
{:app {:target :node-library
:output-dir "target"
:compiler-options {:infer-externs true}
:devtools {:repl-init-ns cljs-time.core
:repl-pprint true}}

:test {:target :node-test
:output-to "target/test.js"
:compiler-options {:infer-externs true}
:autorun true}}}
6 changes: 3 additions & 3 deletions src/cljs_time/internal/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@
millis? (when millis (<= 0 millis 999))
weekyear-week? (when weekyear-week (<= 1 weekyear-week 53))
day-of-week? (when day-of-week (<= 1 day-of-week 7))]
(if (->> [months? days? hours? minutes? seconds? millis?
(if (->> [months? days? hours? minutes? seconds? millis?
weekyear-week? day-of-week?]
(remove nil?)
(every? true?))
(if (not (and (or years months days)
(or weekyear weekyear-week day-of-week)))
(or weekyear weekyear-week)))
d
(throw
(throw
(ex-info "Mixing year, month, day and week-year week-number fields"
{:type :invalid-date :date d
:errors {}})))
Expand Down
18 changes: 10 additions & 8 deletions src/cljs_time/internal/parse.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@
[[:meridiem (keyword meridiem)] (string/join s)]))))

(defn parse-period-name [s period periods short?]
(let [periods (concat periods (map #(subs % 0 3) periods))
[m s] (->> periods
(let [all-periods (concat periods (map #(subs % 0 3) periods))
[m s] (->> all-periods
(map #(-> [% (replace s (re-pattern (str \^ %)) "")]))
(remove (comp (partial = s) second))
(first))]
(if m
[[period (mod (i/index-of periods m) 12)] s]
[[period (mod (i/index-of all-periods m) (count periods))] s]
(throw (ex-info (str "Could not parse " (name period) " name")
{:type :parse-error
:sub-type :period-match-erroro
Expand All @@ -210,8 +210,10 @@
(-> (parse-period-name s :months i/months short?)
(update-in [0 1] inc))))

(defn parse-day-name [short?]
(fn [s] (parse-period-name s :days i/days short?)))
(defn parse-day-of-week-name [short?]
(fn [s]
(let [[[period value] s] (parse-period-name s :day-of-week i/days short?)]
[[period (if (= value 0) 7 value)] s])))

(defn parse-quoted [quoted]
(let [qpat (re-pattern (apply str \^ quoted))]
Expand Down Expand Up @@ -264,9 +266,9 @@
"xxxx" (parse-weekyear 4 4)
"w" (parse-weekyear-week 1 2)
"ww" (parse-weekyear-week 2 2)
"E" (parse-day-name true)
"EEE" (parse-day-name true)
"EEEE" (parse-day-name false)
"E" (parse-day-of-week-name true)
"EEE" (parse-day-of-week-name true)
"EEEE" (parse-day-of-week-name false)
"e" (parse-day-of-week 1 2)
"a" (parse-meridiem)
"A" (parse-meridiem)
Expand Down
3 changes: 1 addition & 2 deletions test/cljs_time/extend_test.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(ns cljs-time.extend-test
(:require-macros
[cljs.test :refer [deftest is]])
(:require
[cljs.test :refer-macros [deftest is]]
[cljs-time.core :as time]
[cljs-time.extend :as extend])
(:import
Expand Down
28 changes: 26 additions & 2 deletions test/cljs_time/format_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
(deftest parse-test
(is (= [2013 8 28 14 26 0 0]
(utc-int-vec
(format/parse (formatter "do MMM yyyy HH:mm") "28th August 2013 14:26"))))
(format/parse (formatter "do MMM yyyy HH:mm") "28th August 2013 14:26"))))
(is
(= :invalid-date
(try
Expand Down Expand Up @@ -81,7 +81,31 @@
(is (= [2018 3 27 10 44 23 22]
(utc-int-vec
(format/parse (formatter "yyyy-MM-dd'T'HH:mm:ss.SSSSZZ")
"2018-03-27T10:44:23.022787+00:00")))))
"2018-03-27T10:44:23.022787+00:00"))))
(is (= [2021 1 31 00 00 00 00]
(utc-int-vec
(format/parse (formatter "yyyy-MM-dd, E")
"2021-01-31, Sun"))))
(is (= [2021 1 31 00 00 00 00]
(utc-int-vec
(format/parse (formatter "yyyy-MM-dd, EEEE")
"2021-01-31, Sunday"))))
(is (= [2021 1 31 00 00 00 00]
(utc-int-vec
(format/parse (formatter "E, yyyy-MM-dd")
"Sun, 2021-01-31"))))
(is (= [2021 1 31 00 00 00 00]
(utc-int-vec
(format/parse (formatter "EEEE, yyyy-MM-dd")
"Sunday, 2021-01-31"))))
(is (= [2021 2 1 00 00 00 00]
(utc-int-vec
(format/parse (formatter "EEE, yyyy-MM-dd")
"Mon, 2021-02-01"))))
(is (= [2021 2 1 00 00 00 00]
(utc-int-vec
(format/parse (formatter "yyyy-MM-dd, EEE")
"2021-02-01, Mon")))))

(deftest unparse-test
(let [date (from-date #inst "2013-08-29T00:00:00.000-00:00")]
Expand Down