Is it possible that you are still using a module that overrides the builtin localtime function? I did mention that my example did use the builtin. (to be complete, I tested the same with use Time::Local; and use Time::Piece;, and both passed too).
I ran my piece of example code through every version of perl ever released since 5.6.0, and they all work as expected. Here is the shortened list of results (I skipped all development releases and older versions of stable branches, but included 5.8.8):
$ cat test.pl
use strict;
use warnings;
sub timestamp
{
my @st = localtime (shift);
return sprintf "%04d-%02d-%02dT%02d:%02d:%02d.000-0700",
$st[5] + 1900, ++$st[4], @st[3,2,1,0];
}
sub starttimestamp { return timestamp (time); }
sub endtimestamp { return timestamp (time + (15 * 60)); }
sub futuretimestamp { return timestamp (time + shift); }
my $fts = futuretimestamp (162 * 60 * 60); # Stamp 162 hours ahead
print $fts, "\n";
$ perl-all test.pl
=== base/perl5.6.2 5.006002 i686-linux-64int-perlio
2013-12-02T06:46:51.000-0700
=== base/tperl5.6.2 5.006002 i686-linux-thread-multi-64int-ld-perli
+o
2013-12-02T06:46:52.000-0700
=== base/perl5.8.8 5.008008 i686-linux-64int
2013-12-02T06:46:56.000-0700
=== base/tperl5.8.8 5.008008 i686-linux-thread-multi-64int-ld
2013-12-02T06:46:56.000-0700
=== base/perl5.8.9 5.008009 i686-linux-64int
2013-12-02T06:46:56.000-0700
=== base/tperl5.8.9 5.008009 i686-linux-thread-multi-64int-ld
2013-12-02T06:46:57.000-0700
=== base/perl5.10.1 5.010001 i686-linux-64int
2013-12-02T06:46:58.000-0700
=== base/tperl5.10.1 5.010001 i686-linux-thread-multi-64int-ld
2013-12-02T06:46:58.000-0700
=== base/perl5.12.5 5.012005 i686-linux-64int
2013-12-02T06:47:05.000-0700
=== base/tperl5.12.5 5.012005 i686-linux-thread-multi-64int-ld
2013-12-02T06:47:05.000-0700
=== base/cperl5.14.4 5.014004 i686-linux-64int-ld
2013-12-02T06:47:15.000-0700
=== base/perl5.14.4 5.014004 i686-linux-64int
2013-12-02T06:47:16.000-0700
=== base/tperl5.14.4 5.014004 i686-linux-thread-multi-64int-ld
2013-12-02T06:47:16.000-0700
=== base/cperl5.16.3 5.016003 i686-linux-64int-ld
2013-12-02T06:47:25.000-0700
=== base/perl5.16.3 5.016003 i686-linux-64int
2013-12-02T06:47:25.000-0700
=== base/tperl5.16.3 5.016003 i686-linux-thread-multi-64int-ld
2013-12-02T06:47:26.000-0700
=== base/cperl5.18.2 5.018002 i686-linux-64int-ld
2013-12-02T06:47:36.000-0700
=== base/perl5.18.2 5.018002 i686-linux-64int
2013-12-02T06:47:37.000-0700
=== base/tperl5.18.2 5.018002 i686-linux-thread-multi-64int-ld
2013-12-02T06:47:37.000-0700
Enjoy, Have FUN! H.Merijn