Date Script Service

Last modified by Admin on 2024/12/11 00:49

calendar_view_dayScript services to display dates in a nice way.
TypeJAR
CategoryAPI
Developed by

XWiki Development Team

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Standard

Compatibility

Since XWiki 10.5-rc-1 and XWiki 9.11.5.

Installable with the Extension Manager

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:

## Example 1:
$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).

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 16.10.1):

Get Connected