diff --git a/frontend/src/uxbox/main/ui/dashboard/icons.cljs b/frontend/src/uxbox/main/ui/dashboard/icons.cljs index bbfaf3941e..fff2401bb2 100644 --- a/frontend/src/uxbox/main/ui/dashboard/icons.cljs +++ b/frontend/src/uxbox/main/ui/dashboard/icons.cljs @@ -300,7 +300,7 @@ :default-value (:name icon)}] [:h3 {:on-double-click on-edit} (:name icon)]) - (str (tr "ds.uploaded-at" (dt/format (:created-at icon) "DD/MM/YYYY")))]])) + (str (tr "ds.uploaded-at" (dt/format (:created-at icon) "dd/MM/yyyy")))]])) ;; --- Grid diff --git a/frontend/src/uxbox/main/ui/dashboard/projects.cljs b/frontend/src/uxbox/main/ui/dashboard/projects.cljs index bbb5e358cf..8d1dcb14d2 100644 --- a/frontend/src/uxbox/main/ui/dashboard/projects.cljs +++ b/frontend/src/uxbox/main/ui/dashboard/projects.cljs @@ -75,6 +75,12 @@ ;; --- Grid Item +(mf/defc grid-item-metadata + [{:keys [modified-at]}] + (let [locale (i18n/use-locale) + time (dt/timeago modified-at {:locale locale})] + (str (t locale "ds.updated-at" time)))) + (mf/defc grid-item {:wrap [mf/wrap-memo]} [{:keys [file] :as props}] @@ -105,9 +111,7 @@ ;; :on-click on-edit :default-value (:name file)}] [:h3 (:name file)]) - [:span.date - (str (tr "ds.updated-at" (dt/timeago (:modified-at file))))]] - + [:& grid-item-metadata {:modified-at (:modified-at file)}]] [:div.project-th-actions ;; [:div.project-th-icon.pages ;; i/page diff --git a/frontend/src/uxbox/main/ui/shapes/circle.cljs b/frontend/src/uxbox/main/ui/shapes/circle.cljs index 947b0b1e81..694fdcdae5 100644 --- a/frontend/src/uxbox/main/ui/shapes/circle.cljs +++ b/frontend/src/uxbox/main/ui/shapes/circle.cljs @@ -47,7 +47,7 @@ transform (when (pos? rotation) (str (-> (gmt/matrix) - (gmt/rotate* rotation center)))) + (gmt/rotate rotation center)))) props {:id (str "shape-" id) :class (classnames :move-cursor moving?) diff --git a/frontend/src/uxbox/main/ui/shapes/icon.cljs b/frontend/src/uxbox/main/ui/shapes/icon.cljs index e87cd59b79..6ab6ae9f9c 100644 --- a/frontend/src/uxbox/main/ui/shapes/icon.cljs +++ b/frontend/src/uxbox/main/ui/shapes/icon.cljs @@ -38,7 +38,7 @@ (let [x-center (+ x1 (/ width 2)) y-center (+ y1 (/ height 2)) center (gpt/point x-center y-center)] - (gmt/rotate* mt rotation center))) + (gmt/rotate mt rotation center))) (mf/defc icon-shape [{:keys [shape] :as props}] diff --git a/frontend/src/uxbox/util/geom/matrix.cljs b/frontend/src/uxbox/util/geom/matrix.cljs index dc190cc243..f99e96c4ef 100644 --- a/frontend/src/uxbox/util/geom/matrix.cljs +++ b/frontend/src/uxbox/util/geom/matrix.cljs @@ -75,9 +75,6 @@ (rotate-matrix angle) (translate-matrix (gpt/negate center))))) -;; TODO: temporal backward compatibility -(def rotate* rotate) - (defn scale "Apply scale transformation to the matrix." ([m scale] (multiply m (scale-matrix scale))) diff --git a/frontend/src/uxbox/util/time.cljs b/frontend/src/uxbox/util/time.cljs index 33b943baab..8539cc28cf 100644 --- a/frontend/src/uxbox/util/time.cljs +++ b/frontend/src/uxbox/util/time.cljs @@ -2,38 +2,36 @@ ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; -;; Copyright (c) 2015-2017 Andrey Antukh +;; This Source Code Form is "Incompatible With Secondary Licenses", as +;; defined by the Mozilla Public License, v. 2.0. +;; +;; Copyright (c) 2015-2020 Andrey Antukh (ns uxbox.util.time - (:require [vendor.datefns] - [cognitect.transit :as t])) + (:require + [vendor.datefns] + [goog.object :as gobj])) (def ^:private dateFns js/dateFns) - -(defn format - "Returns a string representation of the Instant - instance with optional `fmt` format parameter. - - You can use `:iso` and `:unix` shortcuts as - format parameter. - - You can read more about format tokens here: - http://momentjs.com/docs/#/displaying/format/ - " - ([v] (format v :iso)) - ([v fmt] - {:pre [(inst? v)]} - (case fmt - :offset (.getTime v) - :iso (.format dateFns v) - (.format dateFns v fmt)))) +(def ^:private locales (gobj/get js/dateFns "locales")) (defn now "Return the current Instant." [] (js/Date.)) +(defn format + ([v fmt] (format v fmt nil)) + ([v fmt {:keys [locale] + :or {locale "default"}}] + (.format dateFns v fmt #js {:locale (gobj/get locales locale)}))) + (defn timeago - [v] - {:pre [(inst? v)]} - (.distanceInWordsToNow dateFns v)) + ([v] (timeago v nil)) + ([v {:keys [seconds? locale] + :or {seconds? true + locale "default"}}] + (.formatDistanceToNow dateFns v + #js {:includeSeconds seconds? + :addSuffix true + :locale (gobj/get locales locale)})))