[rt-users] date formatting

david.falkenburger at rbc.com david.falkenburger at rbc.com
Fri Jul 16 11:32:42 EDT 2004


Wondering if RT has this functionality and I missed it somewhere. If it does
not, it may be useful for some that want more control over the formatting of
the date. Then from templates, or where ever you want to print the date, can
use something like 
 
$Ticket->CreatedObj->DateFormat(TEMPLATE)
passing it the format string you want the date output in TEMPLATE. Create
the string using any of the allowable format parameters from Date::Format,
there is quite a few.
 
eg. In a template can have something like:  
On {$Ticket->CreatedObj->DateFormat("%B %e, %Y")} your machine was detected
to have unauthorized software.
would result in: 
On July 16, 2004 your machine was detected to have unauthorized software.
 
Perhaps this could be added to base RT if not there in 3.2.1?
 
 
Created the file:     /opt/rt3/local/lib/Date_Local.pm
 
use Date::Format;
 
sub DateFormat {
    my $self = shift;
    my $template = shift;
    return ($self->loc("Not set")) if ($self->Unix <= 0);
 
    return (time2str($template,$self->Unix));
}

Dave

------------------------------------------------------------
This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately. 

Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce pas aux droits et obligations qui s'y rapportent. Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) désigné(s) est interdite. Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser immédiatement, par retour de courrier électronique ou par un autre moyen.

============================================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20040716/e8d5e68a/attachment.htm>


More information about the rt-users mailing list