Skip to content

Commit

Permalink
add tzoffset shim method
Browse files Browse the repository at this point in the history
This should allow users time to fix their templates, along with
instructions on how to do so.

Refs #461
  • Loading branch information
preaction committed Feb 18, 2016
1 parent 5b7e219 commit 7ecf559
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/Statocles/Help/Upgrading.pod
Expand Up @@ -76,27 +76,26 @@ without bells and whistles, the Basic app can be used.

The Static app will be removed in v2.000.

=back

=head1 BREAKING CHANGES

=head2 v0.070

=over 4

=item Error in template: Can't locate object method "tzoffset" via package "DateTime::Moonpig"
=item The tzoffset shim method will be removed in Statocles version 2.0.

In order to allow documents dated before 1900, Statocles is now using
a different date/time library, L<DateTime::Moonpig>. This new library
is mostly compatible, except for the the C<tzoffset> method, which is
used by the RSS feed because it uses the RFC822 date format.

Statocles adds a shim method that replicates the functionality, but it
is a better idea to fix your templates to use the correct method.

To fix this, copy the C<blog/index.rss.ep> template from the default
theme, or change C<$p-E<gt>date-E<gt>tzoffset / 36> in the C<pubDate>
tag to C<$p-E<gt>date-E<gt>offset / 3600>.

Deprecated in v0.070. Will be removed in v2.000.

=back

=head1 BREAKING CHANGES

=head2 v0.055

=over 4
Expand Down
6 changes: 6 additions & 0 deletions lib/Statocles/Types.pm
Expand Up @@ -71,6 +71,12 @@ coerce DateTimeObj, from DateTimeStr, via {
);
};

sub DateTime::Moonpig::tzoffset {
my ( $self ) = @_;
warn "The tzoffset shim method will be removed in Statocles version 2.0. See Statocles::Help::Upgrading for instructions to remove this warning.\n";
return $self->offset * 100;
}

# Down here to resolve circular dependencies
require Statocles::Store;
require Statocles::Link;
Expand Down
17 changes: 17 additions & 0 deletions t/deprecated.t
Expand Up @@ -156,4 +156,21 @@ subtest 'Statocles::App::Static' => sub {
}
};

subtest 'tzoffset shim' => sub {
use Statocles::Types qw( DateTimeObj );
if ( $Statocles::VERSION < 2 ) {
my $dt = DateTimeObj->coerce( '2015-01-01' );
ok $dt->can( 'tzoffset' ), 'tzoffset method exists';

my @warnings;
local $SIG{__WARN__} = sub { push @warnings, @_ };
is $dt->tzoffset, 0, 'tzoffset is correct';
like $warnings[0], qr{\QThe tzoffset shim method will be removed in Statocles version 2.0. See Statocles::Help::Upgrading for instructions to remove this warning.}, 'warn on tzoffset method';
}
else {
my $dt = DateTimeObj->coerce( '2015-01-01' );
ok !$dt->can( 'tzoffset' ), 'tzoffset method does not exist';
}
};

done_testing;

0 comments on commit 7ecf559

Please sign in to comment.