Giter VIP home page Giter VIP logo

humanize's People

Contributors

abhinavomprakash avatar athos avatar bilus avatar danielcompton avatar hlship avatar jall avatar kongeor avatar malesch avatar oakmac avatar seancorfield avatar stathissideris avatar trhura avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

humanize's Issues

Rename top-level namespace to cljs-commons

From PR-31:

One thing I will say about this project: using clojure.* for a non-official project is a big no-no, and using clojure.contrib.* doubly so, so when this library gets overhauled, I would strongly recommend changing the top-level namespace.

I agree with this assessment by @seancorfield and think it would appropriate to change the top-level ns for this project.

Since it is planned to move to clj-commons, maybe the following:

  • clojure.contrib.humanize --> clj-commons.humanize.core
  • clojure.contrib.inflect --> clj-commons.humanize.inflect
  • clojure.contrib.macros --> removed by PR-31

Dynamic atoms in clojure.contrib.inflect?

In clojure.contrib.inflect, *pluralize-noun-rules* and *pluralize-noun-exceptions* are ^:dynamic, but their root values are never rewritten, instead the atoms inside the reference are rewritten. Is this intentional? If not, they can be converted to ordinary, non-dynamic, non-earmuff vars.

oxford has one too many commas with 2 items

Hi,

Thanks for this library. It's really useful. I was just chatting with a colleague about producing a list with an oxford comma using butlast. Then I found this, which is excellent.

I just noticed that the output for 2 items is:

(oxford ["apple" "orange"]) --> "apple, and orange"

when there should be no comma when there are only 2 items in the list.

Clojurescript support

It would be nice to have clojurescript support as UIs can really benefit from this library.

With clojure 1.7+ using reader conditionals this can be done.

The tests are passing for both clj and cljs.

Should I do some cleanup and make a PR?

Pluralize doesn't handle 'chief'

I like where you're going with this library. Here are some suggestions to help improve it.

The plural of "chief" is "chiefs", not "chieves".

user> (clojure.contrib.inflect/pluralize-noun 2 "chief" )
"chieves"

On a separate note, there is a spelling mistake in the README examples. This

user> (clojure.contrib.inflect/pluralize-noun 2 "theif" )
"theives"

Should be

user> (clojure.contrib.inflect/pluralize-noun 2 "thief" )
"thieves"

Loading exception when clj-time 0.11.0 is added to project

create a new project:

lein new app humanize-bug

add clojure-humanize and clj-time deps to project.clj

:dependencies [
  [org.clojure/clojure "1.8.0"]
  [clojure-humanize "0.1.0"]
  [clj-time "0.11.0"]
  ]

require humanize in core.clj:

(ns humanize-bug.core
  (:gen-class)
  (:require [clojure.contrib.humanize :refer [truncate]]))

(defn -main
  "I don't do a whole lot ... yet."
  [& args]
  (println (truncate (first args) 5)))

lein run "hello world"

expected:
he...
actual:

Exception in thread "main" java.lang.IllegalStateException: to-local-date-time already refers to: #'clj-time.local/to-local-date-time in namespace: clojure.contrib.humanize, compiling:(clojure/contrib/humanize.clj:1:1)

Suggestion: Elapsed time

Here's a bit of code I use to humanize an elapsed period of time:

(def ^:private humanized-periods
  [[(* 1000 60 60 24 7) "week"]
   [(* 1000 60 60 24) "day"]
   [(* 1000 60 60) "hour"]
   [(* 1000 60) "minute"]
   [1000 "second"]])

(defn humanize-ellapsed-ms
  [ms]
  (let [periods (loop [remainder ms
                       [[period-ms period-name] & more-periods] humanized-periods
                       terms []]
                  (cond-let
                    (nil? period-ms)
                    terms

                    (< remainder period-ms)
                    (recur remainder more-periods terms)

                    :else
                    (let
                      [period-count (int (/ remainder period-ms))
                       next-remainder (mod remainder period-ms)
                       formatted (str period-count " " period-name
                                      (when-not (= 1 period-count) "s"))]
                      (recur next-remainder
                             more-periods
                             (conj terms formatted)))))]
    (str/join ", " periods)))

cond-let is from io.aviso/toolchest.

when will version 0.2.1 be released?

Thanks a ton for your work on Clojure-humanize!

I just saw that the "duration" function has been recently added to version 0.2.1 . I was just wondering if there is anything blocking you from release this version to Clojars. I will be happy to help if there is something that I can do to help

Upgrade dependencies for 2020

Hi,

I love the idea of the library. I just tried bringing it in though and I see lein grabbing clj-time 0.12.0. We're already bringing in 0.15.2. This sounds just dicey enough to keep me from using the library.

It'd be nice just to give things a once-over and publish a current version.

Let me know if I could help.

clj-commons.humanize/datetime fails with java.time.LocalDateTime in cljs

In cljs env with the following versions:

org.clj-commons/humanize {:mvn/version "1.0"}
thheller/shadow-cljs     {:mvn/version "2.25.5"}
tick/tick                {:mvn/version "0.6.2"}

running any one of:

(h/datetime)
(h/datetime (js/Date.))
(require '[tick.core :as t])
(h/datetime (t/now))

results in the same exception:

(h/datetime)
:repl/exception!
; 
; Execution error (ExceptionInfo) at (<cljs repl>:1).
; unable to coerce to java.time.LocalDateTime

Release

Hi,

Would you be so kind of release a non-snapshot version to clojars? We would like to include your library in a project but we cannot use any snapshot dependencies on production.

Thanks,

Daniel

Oxford isn't oxford

oxford doesn't seem to actually use an oxford comma. I believe the correct output would be:

user> (clojure.contrib.humanize/oxford ["apple" "orange" "mango"])
"apple, orange, and mango"

(Note the comma after orange :) )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.