[Canberra-pm] configuring ISO 8601 date output using Template module

John.Hockaday at ga.gov.au John.Hockaday at ga.gov.au
Mon Feb 5 18:07:28 PST 2007


Hi All,

I have a script that uses the Template PERL module to create an XML document
from the hash table pulled out of a RDBMS.  Part of the template processing
code is:
###########################################
sub processTemplate {
  my ($data, $filename) = @_;

  my ($outfile) = $outdir . "/" . $filename . ".xml";
  open (my $fh, "> $outfile") or die "Can't open the output file $outfile: $!
^?\n";

  my $config = {  INCLUDE_PATH    =>      $outdir,
                  TAG_STYLE       =>      'html',
                  PRE_CHOMP       =>      1,
               };

  my $tt = Template->new($config);
  my $templatefile = "anztemp.xml";

  $tt->process("$templatefile", $data, $fh) || die $tt->error;
  close $fh;

} #End processTemplate
#########################################

Part of the template to generate the XML is:

#########################################
  <metainfo>
    <metd>
      <date>
<!-- LASTUPDATE -->
      </date>
    </metd>
  </metainfo>
#########################################

The trouble is that the LASTUPDATE date (Oracle RDBMS) is in the form
DD-MON-YYYY  whereas I want ISO 8601 format like YYYY-MM-DD.  Can I insert a
filter or something to change the format of the date?  If so what should the
code look like.

Thanks in advance for your help.


John Hockaday
Geoscience Australia
GPO Box 378
Canberra ACT 2601
(02) 6249 9735
http://www.ga.gov.au/ 
john.hockaday\@ga.gov.au


More information about the Canberra-pm mailing list