A plugin that allows you to display human readable, relative timestamps.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
gradle/wrapper fix broken gradle stuff 4.0.0 release, update deps for joda-time and … Jan 5, 2016
grails-app upgraded to the grails 3 Jun 27, 2015
src upgraded to the grails 3 Jun 27, 2015
.gitignore fix broken gradle stuff 4.0.0 release, update deps for joda-time and … Jan 5, 2016
README.md Fought a bit with grails 2.x Oct 11, 2018
application.properties Updated dependecies Aug 4, 2013
build.gradle
gradle.properties
gradlew upgraded to the grails 3 Jun 27, 2015
gradlew.bat upgraded to the grails 3 Jun 27, 2015

README.md

PrettyTime

PrettyTime is an OpenSource time formatting library. PrettyTime creates human readable, relative timestamps like those seen on Digg, Twitter, and Facebook. It’s simple, get started “right now!” and in over 25 languages!

This plugin allows you to display human readable, relative timestamps. It is based on PrettyTime OpenSource time formatting library.

Installation

compile ":pretty-time:3.0.2.Final-1.0.0"

Installation for 2.x

grails install-plugin pretty-time
plugins {
    compile ":pretty-time:2.1.3.Final-1.0.1"
}

Requirements

  • Grails 2.0 or above
  • for Grails 1.x use version 0.3

Usage

<prettytime:display date="${someDate}" />

outputs:

"right now", "2 days ago", or "3 months from now"

Internationalization (I18n)

Build in - uses prettytime library translations. TagLib included in this plugin respects current locale.

Tag attributes

Attribute Description
date The date object to format.
capitalize Capitalize the output text (default: false). Ex: "moments ago" will be capitalized to "Moments ago".
showTime Show the time (default: false). Ex: "2 days ago, 12:00:25 AM".
html5wrapper Wrap the output text (default: false). Ex: "moments ago" will be wrapped with "<time datetime="some date" title="some date">moments ago</time>".
format The format to use for the date (default: "hh:mm:ss a"). The default value is set by "default.date.format" in I18n.