5 minutes is default minimum duration?

Splash Forums PrettyTime Users 5 minutes is default minimum duration?

This topic contains 4 replies, has 2 voices, and was last updated by  Lincoln Baxter III 4 years, 9 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #18662

    Toldmeego
    Member

    It looks like by default, all durations below 5 minutes are labelled “moments ago”.

    Is there a simple way to control this tolerance? Is it rounding?

    I would like to show:

    – minutes ago

    – seconds ago

    Milliseconds ago are fine to show as “moments ago”.

    #22874

    Toldmeego
    Member

    On the website, it even says: Convert elapsed timestamps, like, “in 3 minutes!”

    GitHub issue: https://github.com/ocpsoft/prettytime/issues/23

    #22875

    Hey Hawleyal,

    Sorry for the slow response. Yes, you can do this, but you’ll need to do a line or two of setup:

    PrettyTime p = new PrettyTime();
    List<TimeUnit> units = new ArrayList<TimeUnit>();
    for( TimeUnit t : p.getUnits() ) {
    if(!(t instanceof JustNow) {
    units.add(t);
    }
    }
    p.setUnits(units);

    The reason you can’t just remove the unit is due to Thread safety issues, but now that you bring this up, I think we should improbably improve this process in the API for PrettyTime 2.0 (coming soon.)

    I hope this helps,

    ~Lincoln

    #22876

    Toldmeego
    Member

    Your response was extremely fast. No worries.

    Thanks a TON!

    Missing a trailing parenthesis in the if.

    Works.

    PrettyTime p = new PrettyTime();
    List<TimeUnit> units = new ArrayList<TimeUnit>();
    for( TimeUnit t : p.getUnits() ) {
    if(!(t instanceof JustNow)) {
    units.add(t);
    }
    }
    p.setUnits(units);

    I owe you a paypal donation :)

    #22877

    Awesome! Thanks :) Well… typos are just proof that I was doing this all in my head :p

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Comments are closed.