Download

Get Loom

Format tags

These tags are used to print "humanized" information in a reasonable way, instead of the harder format used by the system by default.

FormatFileSizeTag

Represent a file size in the best available measure units (KB, bytes, MB, etc):

<%-- print 123.5 KB --%>
<l:formatFileSize value="${123.5 * 1024}"/>

<%-- print 123.5 MB --%>
<l:formatFileSize value="${123.52 * 1024 * 1024}" precision="1"/>

FormatDateTag

Calculate a Date relative to today:

<%-- print "two months ago", "in 2 days", etc --%>
<l:formatDate value="${myDate}"/>

The same behavior is provided by Date.humanized(), present in format.js:

alert(new Date().humanized()); // -> "less than one minute ago"

FormatDurationTag

Formats a time elapsed in days, hours, minutes and seconds.

<%-- print for example "2 hours 10 minutes 2 seconds" --%>
<l:formatDuration value="${myDurationInMillis}"/>

Equivalent to Date.toDuration().humanized() in format.js

alert(date.toDuration().humanized());