Browse Source

fix: :Xd-after/before input always returns today's date in a query

related to #5424
Tienson Qin 3 years ago
parent
commit
b0349a8511
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/main/frontend/db/query_react.cljs

+ 2 - 2
src/main/frontend/db/query_react.cljs

@@ -33,12 +33,12 @@
     (and (keyword? input)
          (util/safe-re-find #"^\d+d(-before)?$" (name input)))
     (let [input (name input)
-          days (parse-long (subs input 0 (dec (count input))))]
+          days (parse-long (re-find #"^\d+" input))]
       (date->int (t/minus (t/today) (t/days days))))
     (and (keyword? input)
          (util/safe-re-find #"^\d+d(-after)?$" (name input)))
     (let [input (name input)
-          days (parse-long (subs input 0 (dec (count input))))]
+          days (parse-long (re-find #"^\d+" input))]
       (date->int (t/plus (t/today) (t/days days))))
 
     (and (string? input) (text/page-ref? input))