Details
-
Improvement
-
Resolution: Unresolved
-
Major
-
None
-
8.4
-
None
-
Unknown
-
Description
This is needed for XWIKI-14894 for example.
Right now it's hardcoded in XWiki.formatDate():
public String formatDate(Date date, String format, XWikiContext context)
{
if (date == null) {
return "";
}
String xformat = format;
String defaultFormat = "yyyy/MM/dd HH:mm";
if (format == null) {
xformat = getXWikiPreference("dateformat", defaultFormat, context);
}
...
For now I'm proposing to add 2 new methods:
/**
* @return the default format used by XWiki for dates when the user hasn't configured a format
* @since 9.11RC1
*/
@Unstable
public String getDefaultDateFormat()
{
return DEFAULT_DATE_FORMAT;
}
/**
* @return the format used by XWiki for dates
* @since 9.11RC1
*/
@Unstable
public String getDateFormat(XWikiContext context)
{
return getXWikiPreference("dateformat", getDefaultDateFormat(), context);
}
Note that in the future we'll need a better place. One idea would be add those methods in CoreConfiguration.
Also note that we'll need a scripting API in the future. For example I noticed this in macros.vm:
<input type="text" data-type="date" data-dateformat='$escapetool.html($xwiki.getXWikiPreference("dateformat", "yyyy/MM/dd HH:mm"))' #if("$!colprop.size" != '') size="${colprop.size}" title="$escapetool.xml($services.localization.render('platform.livetable.filtersTitle', [$services.localization.render("${transprefix}${colname}")]))"#end />
Right now AFAIK we don't a "core" ScriptService to expose configuration values. Right?
Attachments
Issue Links
- blocks
-
XWIKI-14894 XWiki Date tool is not using XWiki's date format
-
- In Progress
-
- relates to
-
XWIKI-19807 Proper java API to perform Date Formatting
-
- Open
-