At 15:52 -0400 18/08/2011, Ronald J Kimball wrote:

Although you add 1900 to the year, I think you forgot to add 1 to the month
returned by localtime.

Yep :-[

Here are two alternate ways to format today's date:

my @date = localtime;
my $date = sprintf "%04d-%02d-%02d", $date[5] + 1900, $date[4] + 1, $date[3];

use POSIX qw/ strftime /;
my $date = strftime "%Y-%m-%d", localtime;

Yes.  In fact you might as well skip localtime altogether and do this:

#!/usr/local/bin/perl
use strict;
chomp (my $date = `date "+%Y-%m-%d"`);
while (<>) {
  s~(<imported>)[0-9]{4}-[0-9]{2}-[0-9]{2}(</imported>)~$1$date$2~g;
  print;
}

# JD

--
You received this message because you are subscribed to the "BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, please email "supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to