Date Script Service
![]() | Script services to display dates in a nice way. |
Type | JAR |
Category | API |
Developed by | XWiki Development Team |
Rating | |
License | GNU Lesser General Public License 2.1 |
Bundled With | XWiki Standard |
Description
This script services offer some methods to display dates in a pretty way, and supporting a lot of locales (contrary to $datetool). It is currently based on PrettyTime.
Examples
Here are some Velocity examples:
$services.date.displayTimeAgo($datetool.date())
## Displays: moments from now ("à l'instant" in French)
## Example 2:
$services.date.displayTimeAgo($xwiki.jodatime.dateTime.minusMinutes(12).toDate())
## Displays: 12 minutes ago ("il y a 12 minutes" in French)
## Example3: You can also specify the locale you want
$services.date.displayTimeAgo($xwiki.jodatime.dateTime.minusHours(1).toDate(), "es")
## Displays "hace 1 hora"
Prerequisites & Installation Instructions
We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.
You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.
Dependencies
Dependencies for this extension (org.xwiki.platform:xwiki-platform-date 12.10.2):
- org.xwiki.commons:xwiki-commons-component-api 12.10.2
- org.xwiki.commons:xwiki-commons-script 12.10.2
- org.xwiki.platform:xwiki-platform-localization-api 12.10.2
- org.ocpsoft.prettytime:prettytime 4.0.1.Final