BuzzSaw
view release on metacpan or search on metacpan
lib/BuzzSaw/DB/Schema/Result/Event.pm view on Meta::CPAN
Type: has_many
Related object: L<BuzzSaw::DB::Schema::Result::ExtraInfo>
=cut
__PACKAGE__->has_many(
'extra_info',
'BuzzSaw::DB::Schema::Result::ExtraInfo',
{ 'foreign.event' => 'self.id' },
);
sub localtime {
my ($self) = @_;
# This might just count as hack of the week!
use feature 'state';
require DateTime::TimeZone;
state $localtz = DateTime::TimeZone->new( name => 'local' );
# When a specially computed localtime column exists we get the
# value and inflate to a datetime object. When it does not exist
# we copy the logtime object and shift to the local timezone. The
# second option is much slower for large numbers of rows but
# should always work.
my $dt = try {
my $timestamp = $self->get_column('localtime');
my $dtf = $self->result_source->storage->datetime_parser();
$dtf->parse_datetime($timestamp);
} catch {
my $clone = $self->logtime->clone();
$clone->set_time_zone($localtz);
};
return $dt;
}
1;
__END__
=head1 DEPENDENCIES
This module requires L<DBIx::Class>, it also needs L<DateTime> and a
C<DateTime::Format> module (e.g. L<DateTime::Format::Pg>) to inflate
the C<logtime> column into something useful.
=head1 SEE ALSO
L<BuzzSaw::DB>, L<BuzzSaw::DB::Schema>
=head1 PLATFORMS
This is the list of platforms on which we have tested this
software. We expect this software to work on any Unix-like platform
which is supported by Perl.
ScientificLinux6
=head1 BUGS AND LIMITATIONS
Please report any bugs or problems (or praise!) to bugs@lcfg.org,
feedback and patches are also always very welcome.
=head1 AUTHOR
Stephen Quinney <squinney@inf.ed.ac.uk>
=head1 LICENSE AND COPYRIGHT
Copyright (C) 2012 University of Edinburgh. All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the terms of the GPL, version 2 or later.
=cut
( run in 0.857 second using v1.01-cache-2.11-cpan-5837b0d9d2c )