view release on metacpan or search on metacpan
inc/My/Module/Build.pm view on Meta::CPAN
or push @depends_on, 'build';
-e 'META.json'
or push @depends_on, 'distmeta';
@depends_on
and $self->depends_on( @depends_on );
return;
}
sub harness_switches {
my ( $self ) = @_;
my @res = $self->SUPER::harness_switches();
foreach ( @res ) {
'-MDevel::Cover' eq $_
or next;
$_ .= '=-db,cover_db,-ignore,inc/,-ignore,eg/';
}
return @res;
}
1;
lib/Astro/App/Satpass2/Copier.pm view on Meta::CPAN
If no argument is passed, it is an accessor, returning the warner
object. If no such object has been assigned, one will be generated.
=head2 attribute_names
print join( ', ', $obj->attribute_names() ), "\n";
This method returns the names of the object's attribute_names.
Subclasses should override this. Immediate subclasses B<should> call
C<SUPER::attribute_names()>, and indirect subclasses B<must> call
C<SUPER::attribute_names()>. A subclass' override would look something like
this:
sub attribute_names {
my ( $self ) = @_;
return ( $self->SUPER::attribute_names(), qw{ foo bar baz } );
}
=head2 class_name_of_record
say 'I am a ', $obj->class_name_of_record();
This method returns the class name of record of the object. By default
this is simply the name of the object's class (i.e. C<ref $obj>, but
subclasses can override this to hide implementation details.
=head2 clone
my $clone = $obj->clone();
This method returns a clone of the original object, taken using
C<Clone::clone()>.
Overrides C<may> call C<SUPER::clone()>. If they do not they bear
complete responsibility for producing a correct clone of the original
object.
=head2 copy
$obj->copy( $copy, %skip );
This method copies the attribute values of the original object into the
attribute_names of the copy object. The original object is returned.
lib/Astro/App/Satpass2/Format.pm view on Meta::CPAN
$self->time_formatter()->round_time( @arg );
$self->{round_time} = $arg[0];
return $self;
} else {
return $self->time_formatter()->round_time();
}
}
sub attribute_names {
my ( $self ) = @_;
return ( $self->SUPER::attribute_names(),
qw{ date_format desired_equinox_dynamical gmt
local_coord parent provider round_time
time_format time_formatter tz
value_formatter
} );
}
{
my %original_value = (
lib/Astro/App/Satpass2/Format.pm view on Meta::CPAN
}
sub warner {
my ( $self, @args ) = @_;
if ( @args ) {
my $warner = $args[0];
if ( my $fmtr = $self->time_formatter() ) {
$fmtr->warner( $warner );
}
}
return $self->SUPER::warner( @args );
}
__PACKAGE__->create_attribute_methods();
1;
=head1 NAME
Astro::App::Satpass2::Format - Format Astro::App::Satpass2 output
lib/Astro/App/Satpass2/Format.pm view on Meta::CPAN
=head2 Accessors and Mutators
=head3 date_format
print 'Date format: ', $fmt->date_format(), "\n";
$fmt->date_format( '%d-%b-%Y' );
The C<date_format> attribute is maintained on behalf of subclasses of
this class, which B<may> (but need not) use it to format dates. This
method B<may> be overridden by subclasses, but the override B<must> call
C<SUPER::date_format>, and return values consistent with the following
description.
This method acts as both accessor and mutator for the C<date_format>
attribute. Without arguments it is an accessor, returning the current
value of the C<date_format> attribute.
If passed an argument, that argument becomes the new value of
C<date_format>, and the object itself is returned so that calls may be
chained.
lib/Astro/App/Satpass2/Format.pm view on Meta::CPAN
"\n";
$fmt->desired_equinox_dynamical(
timegm( 0, 0, 12, 1, 0, 100 ) ); # J2000.0
The C<desired_equinox_dynamical> attribute is maintained on behalf of
subclasses of this class, which B<may> (but need not) use it to
calculate inertial coordinates. If the subclass does not make use of
this attribute it B<must> document the fact.
This method B<may> be overridden by subclasses, but the override B<must>
call C<SUPER::desired_equinox_dynamical>, and return values consistent
with the following description.
This method acts as both accessor and mutator for the
C<desired_equinox_dynamical> attribute. Without arguments it is an
accessor, returning the current value of the
C<desired_equinox_dynamical> attribute.
If passed an argument, that argument becomes the new value of
C<desired_equinox_dynamical>, and the object itself is returned so that
calls may be chained.
lib/Astro/App/Satpass2/Format.pm view on Meta::CPAN
sense) they should not be precessed.
=head3 gmt
print 'Time zone: ', ( $fmt->gmt() ? 'GMT' : 'local' ), "\n";
$fmt->gmt( 1 );
The C<gmt> attribute is maintained on behalf of subclasses of this
class, which B<may> (but need not) use it to decide whether to display
dates in GMT or in the local time zone. This method B<may> be overridden
by subclasses, but the override B<must> call C<SUPER::gmt>, and return
values consistent with the following description.
This method acts as both accessor and mutator for the C<gmt>
attribute. Without arguments it is an accessor, returning the current
value of the C<gmt> attribute. This value is to be interpreted as a
Boolean under the usual Perl rules.
If passed an argument, that argument becomes the new value of
C<gmt>, and the object itself is returned so that calls may be
chained.
=head3 local_coord
print 'Local coord: ', $fmt->local_coord(), "\n";
$fmt->local_coord( 'azel_rng' );
The C<local_coord> attribute is maintained on behalf of subclasses of
this class, which B<may> (but need not) use it to determine what
coordinates to display. This method B<may> be overridden by subclasses,
but the override B<must> call C<SUPER::local_coord>, and return values
consistent with the following description.
This method acts as both accessor and mutator for the C<local_coord>
attribute. Without arguments it is an accessor, returning the current
value of the C<local_coord> attribute.
If passed an argument, that argument becomes the new value of
C<local_coord>, and the object itself is returned so that calls may be
chained. The interpretation of the argument is up to the subclass, but
it is recommended for sanity's sake that the subclasses support at least
lib/Astro/App/Satpass2/Format.pm view on Meta::CPAN
It is further recommended that C<azel_rng> be the default.
=head3 provider
print 'Provider: ', $fmt->provider(), "\n";
$fmt->provider( 'Astro::App::Satpass2 v' . Astro::App::Satpass2->VERSION() );
The C<provider> attribute is maintained on behalf of subclasses of this
class, which B<may> (but need not) use it to identify the provider of
the data for informational purposes. This method B<may> be overridden by
subclasses, but the override B<must> call C<SUPER::provider>, and return
values consistent with the following description.
This method acts as both accessor and mutator for the C<provider>
attribute. Without arguments it is an accessor, returning the current
value of the C<provider> attribute.
If passed an argument, that argument becomes the new value of
C<provider>, and the object itself is returned so that calls may be
chained.
=head3 round_time
print 'Time rounded to: ', $fmt->round_time(), " seconds\n";
$fmt->round_time( 60 );
The C<round_time> attribute is maintained on behalf of subclasses of
this class, which B<may> (but need not) use it to format times. This
method B<may> be overridden by subclasses, but the override B<must> call
C<SUPER::round_time>, and return values consistent with the following
description.
This method acts as both accessor and mutator for the C<round_time>
attribute. Without arguments it is an accessor, returning the current
value of the C<round_time> attribute.
If passed an argument, that argument becomes the new value of
C<round_time>, and the object itself is returned so that calls may be
chained.
lib/Astro/App/Satpass2/Format.pm view on Meta::CPAN
if they use this attribute at all.
=head3 time_format
print 'Time format: ', $fmt->time_format(), "\n";
$fmt->time_format( '%H:%M:%S' );
The C<time_format> attribute is maintained on behalf of subclasses of
this class, which B<may> (but need not) use it to format times. This
method B<may> be overridden by subclasses, but the override B<must> call
C<SUPER::time_format>, and return values consistent with the following
description.
This method acts as both accessor and mutator for the C<time_format>
attribute. Without arguments it is an accessor, returning the current
value of the C<time_format> attribute.
If passed an argument, that argument becomes the new value of
C<time_format>, and the object itself is returned so that calls may be
chained.
lib/Astro/App/Satpass2/Format.pm view on Meta::CPAN
new time formatter's class, if the new formatter object has a different
C<FORMATTER_TYPE()> than the old one.
=head3 tz
print 'Time zone: ', $fmt->tz()->name(), "\n";
$fmt->tz( 'MST7MDT' );
The C<tz> attribute is maintained on behalf of subclasses of this class,
which B<may> (but need not) use it to format times. This method B<may>
be overridden by subclasses, but the override B<must> call C<SUPER::tz>,
and return values consistent with the following description.
This method acts as both accessor and mutator for the C<tz> attribute.
Without arguments it is an accessor, returning the current value of the
C<tz> attribute.
If passed an argument, that argument becomes the new value of C<tz>, and
the object itself is returned so that calls may be chained.
The use of the argument is up to the subclass, but it is
lib/Astro/App/Satpass2/Format.pm view on Meta::CPAN
the default configuration are reported.
=item decode
If this boolean argument is true (in the Perl sense), the
L<decode()|/decode> method is used to obtain the configuration values.
=back
Subclasses that add other ways to configure the object B<must> override
this method. The override B<must> call C<SUPER::config()>, and include
the result in the returned data.
=head2 decode
$fmt->decode( 'desired_equinox_dynamical' );
This method wraps other methods, converting their returned values to
human-readable. The arguments are the name of the method, and its
arguments if any. The return values of methods not explicitly documented
below are not modified.
lib/Astro/App/Satpass2/Format.pm view on Meta::CPAN
=item time_formatter
If called as an accessor, the class name of the object being used to
format the time is returned. If called as a mutator, you still get back
the object reference.
=back
If a subclass overrides this method, the override should either perform
the decoding itself, or delegate to C<SUPER::decode>.
=head1 SEE ALSO
L<Astro::App::Satpass2|Astro::App::Satpass2>, which is the intended user of this
functionality.
L<Astro::Coord::ECI|Astro::Coord::ECI> and associated modules, which are
the intended providers of data for this functionality.
L<Astro::App::Satpass2::Format::Dump|Astro::App::Satpass2::Format::Dump>, which is a
lib/Astro/App/Satpass2/Format/Dump.pm view on Meta::CPAN
'Data::Dumper' => 'Dumper',
'JSON' => 'to_json',
);
{
my $dumper_default;
sub new {
my ( $class, @args ) = @_;
my $self = $class->SUPER::new( @args );
if ( ! $self->dumper() ) {
if ( $dumper_default ) {
$self->dumper( $dumper_default );
} else {
$self->dumper(
'YAML,Data::Dumper'
);
$dumper_default = $self->dumper();
}
}
lib/Astro/App/Satpass2/Format/Template.pm view on Meta::CPAN
use Template;
use Text::Abbrev;
use Text::Wrap qw{ wrap };
our $VERSION = '0.056';
use constant FORMAT_VALUE => 'Astro::App::Satpass2::FormatValue';
sub new {
my ($class, @args) = @_;
my $self = $class->SUPER::new( @args );
# As of 0.020_002 the template definitions are in the
# locale system. The attribute simply holds modifications.
$self->{canned_template} = {};
$self->_new_tt( $self->permissive() );
$self->{default} = {};
$self->{formatter_method} = {};
lib/Astro/App/Satpass2/Format/Template.pm view on Meta::CPAN
FORMAT_VALUE->can( $fmtr_name )
and $self->{warner}->wail(
"Formatter $fmtr_name can not override built-in formatter" );
$self->{formatter_method}{$fmtr_name} =
Astro::App::Satpass2::FormatValue::Formatter->new( $fmtr );
return $self;
}
sub attribute_names {
my ( $self ) = @_;
return ( $self->SUPER::attribute_names(),
qw{ permissive },
);
}
sub config {
my ( $self, %args ) = @_;
my @data = $self->SUPER::config( %args );
# TODO support for the {default} key.
foreach my $name (
sort $args{changes} ?
keys %{ $self->{canned_template} } :
$self->__list_templates()
) {
push @data, [ template => $name,
$self->{canned_template}{$name} ];
lib/Astro/App/Satpass2/Format/Template.pm view on Meta::CPAN
1 == @args
or return $self->$method( @args );
return ( @args, $self->$method( @args ) );
},
);
sub decode {
my ( $self, $method, @args ) = @_;
my $dcdr = $decoder{$method}
or return $self->SUPER::decode( $method, @args );
goto $dcdr;
}
}
sub __default {
my ( $self, @arg ) = @_;
@arg or return $self->{default};
my $action = shift @arg;
@arg or return $self->{default}{$action};
my $attrib = shift @arg;
lib/Astro/App/Satpass2/Format/Template.pm view on Meta::CPAN
$data{title}->title_gravity() eq $data{TITLE_GRAVITY_BOTTOM}
and $output =~ s/ \A \n //smx;
return $output;
}
sub gmt {
my ( $self, @args ) = @_;
if ( @args ) {
$self->time_formatter()->gmt( @args );
return $self->SUPER::gmt( @args );
} else {
return $self->SUPER::gmt();
}
}
sub local_coord {
my ( $self, @args ) = @_;
if ( @args ) {
my $val = $args[0];
defined $val
or $val = $self->DEFAULT_LOCAL_COORD;
defined $self->template( $val )
or $self->wail(
'Unknown local coordinate specification', $val );
return $self->SUPER::local_coord( @args );
} else {
return $self->SUPER::local_coord();
}
}
sub permissive {
my ( $self, @args ) = @_;
if ( @args ) {
if ( $self->{permissive} xor $args[0] ) {
$self->_new_tt( $args[0] );
}
$self->{permissive} = $args[0];
lib/Astro/App/Satpass2/Format/Template.pm view on Meta::CPAN
sub tz {
my ( $self, @args ) = @_;
if ( @args ) {
my $tf = $self->time_formatter();
# We go through the following because the time formatter may
# modify the zone (e.g. if it's using DateTime, zones are
# case-sensitive so we may have done case conversion before
# storing). We want this object to have the time formatter's
# version of the zone.
$tf->tz( @args );
return $self->SUPER::tz( $tf->tz() );
} else {
return $self->SUPER::tz();
}
}
sub _all_events {
my ( $self, $data ) = @_;
ARRAY_REF eq ref $data or return;
my @events;
foreach my $pass ( @{ $data } ) {
push @events, $pass->__raw_events();
lib/Astro/App/Satpass2/Format/Template.pm view on Meta::CPAN
If called as an accessor, the name of the formatter accessed is
prepended to the returned array. If this leaves the returned array with
just one entry, the string C<'undef'> is appended. The return is still
an array in list context, and an array reference in scalar context.
If called as a mutator, you still get back the object reference.
=back
If a subclass overrides this method, the override should either perform
the decoding itself, or delegate to C<SUPER::decode>.
=head3 format
$fmt->format( template => $template, ... );
This method represents the interface to L<Template-Toolkit|Template>,
and all the formatter methods come through here eventually.
The arguments to this method are name/value pairs. The C<template>
argument is required, and is either the name of a template file, or a
lib/Astro/App/Satpass2/FormatTime.pm view on Meta::CPAN
sub attribute_names {
return ( qw{ gmt tz } );
}
{
my %skip = map { $_ => 1 } qw{ back_end };
sub copy {
my ( $self, $copy ) = @_;
return $self->SUPER::copy( $copy, %skip );
}
}
{
my $leader_re = qr{ @{[ __PACKAGE__ ]} :: }smxo;
sub class_name_of_record {
my ( $self ) = @_;
( my $name = ref $self || $self ) =~ s/ \A $leader_re //smx;
return $name;
lib/Astro/App/Satpass2/FormatTime.pm view on Meta::CPAN
set to the given value. If the time is C<undef>, a new time representing
C<01-Jan-2100 00:00:00> is constructed, adjusted, and returned.
=head2 round_time
$ft->round_time( 60 );
print 'Time rounded to ', $ft->round_time(), ' seconds';
This method is both accessor and mutator for the time rounding
specification maintained on behalf of the subclass. If the subclass
overrides this, it B<must> call SUPER::round_time with the same
arguments.
If called with an argument, the argument becomes the new rounding
specification, in seconds. The argument must be an integer number of
seconds, the special-cased strings C<'second'>, C<'minute'> or C<'hour'>
(which specify C<1>, C<60> and C<3600> respectively), or C<undef> or
C<'none'> to turn off rounding. Be aware that if rounding is turned off
the time formatter may truncate the time.
If called without an argument, the current value of the C<round_time>
lib/Astro/App/Satpass2/FormatTime.pm view on Meta::CPAN
This method takes as its argument an epoch time, and returns it rounded
to the precision specified by C<< $ft->round_time() >>.
=head2 tz
$ft->tz( 'mst7mdt' );
print 'Current zone: ', $ft->tz(), "\n";
This method is both accessor and mutator for the time zone, maintained
on behalf of the subclass. If the subclass overrides this, it B<must>
call SUPER::tz with the same arguments.
If called with an argument, the argument becomes the new zone, with
either C<''> or C<undef> representing the default zone. The object is
returned to allow call chaining.
If called without an argument, the current value of the C<tz> attribute
is returned.
=head1 SUPPORT
lib/Astro/App/Satpass2/FormatTime/DateTime.pm view on Meta::CPAN
@CARP_NOT
};
use Astro::App::Satpass2::Locale qw{ __preferred };
use DateTime;
use DateTime::TimeZone;
our $VERSION = '0.056';
sub attribute_names {
my ( $self ) = @_;
return ( qw{ back_end }, $self->SUPER::attribute_names() );
}
sub _dt_class_and_args {
my ( $self ) = @_;
if ( $self->{_back_end} ) {
return (
$self->{_back_end}{class},
$self->{_back_end}{arg},
);
} else {
return ( 'DateTime', [] );
}
}
sub class_name_of_record {
my ( $self ) = @_;
return $self->__back_end_class_name_of_record(
$self->SUPER::class_name_of_record() );
}
sub format_datetime {
my ( $self, $tplt, $time, $gmt ) = @_;
$time = $self->__round_time_value( $time );
if ( has_method( $time, $self->METHOD_USED() ) ) {
return $self->__format_datetime( $time, $tplt );
} else {
ref $time
and $self->wail( 'Unsupported time specification' );
lib/Astro/App/Satpass2/FormatTime/DateTime.pm view on Meta::CPAN
@{ $dt_arg },
);
return $self->__format_datetime( $dt, $tplt );
}
}
sub init {
my ( $self, %arg ) = @_;
exists $arg{back_end}
or $arg{back_end} = undef;
return $self->SUPER::init( %arg );
}
{
my $zone_gmt;
my $zone_local;
sub tz {
my ( $self, @args ) = @_;
lib/Astro/App/Satpass2/FormatTime/DateTime.pm view on Meta::CPAN
or $self->wail(
"'$zone' is not a valid time zone name" );
$zone = $zed;
}
$self->{_tz_obj} = DateTime::TimeZone->new(
name => $zone );
} else {
$self->{_tz_obj} = $zone_local ||=
DateTime::TimeZone->new( name => 'local' );
}
return $self->SUPER::tz( $zone );
} else {
return $self->SUPER::tz();
}
}
sub _get_zone {
my ( $self, $gmt ) = @_;
defined $gmt
or $gmt = $self->gmt();
$gmt and return ( $zone_gmt ||= DateTime::TimeZone->new(
name => 'UTC' ) );
lib/Astro/App/Satpass2/Geocode.pm view on Meta::CPAN
$self->geocoder( delete $args{geocoder} );
$self->init( %args );
return $self;
}
sub attribute_names {
my ( $self ) = @_;
return ( qw{ geocoder }, $self->SUPER::attribute_names() );
}
sub geocode {
my ( $self ) = @_;
$self->wail(
"The @{[ ref $self ]} class does not support geocoding. Use a subclass"
);
return; # wail() does not return, but Perl::Critic does not
# know this.
}
lib/Astro/App/Satpass2/Geocode.pm view on Meta::CPAN
L<warner|Astro::App::Satpass2::Copier/warner>, which correspond to the
same-named mutators.
=head2 geocode
my @rslt = $geocoder->geocode(
'1600 Pennsylvania Ave, Washington DC',
);
This method B<must> be overridden by any subclass. The subclass
B<must not> call C<< $self->SUPER::geocode >>.
This method geocodes the given location, using the underlying geocoder
object, and returns any results found. The result is an array of hash
references, each hash representing one location. The hashes must have
the following keys:
=over
=item description
lib/Astro/App/Satpass2/Macro.pm view on Meta::CPAN
The only one defined at the moment is C<required>, which causes an
exception to be thrown if this object does not implement the named
macro.
=head2 init
$self->init();
This method performs initialization and checking of attributes. It
should not be called by the user. Subclasses that override this method
to add extra attributes should call $self->SUPER::init().
Nothing is returned.
=head2 wail
$macro->wail( 'Something bad happened' );
This convenience method simply delegates to the corresponding
C<Astro::App::Satpass2::Warner> method.
lib/Astro/App/Satpass2/Macro/Code.pm view on Meta::CPAN
load_package
quoter
@CARP_NOT
};
use File::Spec;
our $VERSION = '0.056';
sub init {
my ( $self ) = @_;
$self->SUPER::init();
my $parent = $self->parent();
my %popt = ( complaint => 'wail', fatal => 'wail' );
exists $self->{lib}
and $popt{lib} = $self->expand_tilde( $self->{lib} );
defined $self->{lib}
and not $self->{relative}
and not $self->{lib} =~ m/ \A ~ /smx
and $self->{lib} = File::Spec->rel2abs( $self->{lib} );
my $module = $self->load_package(
\%popt, $self->name(), 'Astro::App::Satpass2::Macro::Code'
lib/Astro/App/Satpass2/Macro/Command.pm view on Meta::CPAN
}
sub def {
my ( $self ) = @_;
my @def = @{ $self->{def} };
return wantarray ? @def : \@def;
}
sub init {
my ( $self ) = @_;
$self->SUPER::init();
ARRAY_REF eq ref $self->{def}
or $self->wail( q{Attribute 'def' must be an array reference} );
$self->{implements} = { map { $_ => 1 } $self->name() };
$self->{completion}
and @{ $self->{completion} } = map { split qr< \s+ >smx }
@{ $self->{completion} };
return;
}
lib/Astro/App/Satpass2/ParseTime.pm view on Meta::CPAN
my $self = { %static };
bless $self, $class;
$self->warner( delete $args{warner} );
$self->base( delete $args{base} );
$self->init( %args );
return $self;
}
sub attribute_names {
my ( $self ) = @_;
return ( $self->SUPER::attribute_names(), qw{
base perltime tz } );
}
sub base {
my ( $self, @args ) = @_;
if ( @args > 0 ) {
$self->{base} = $self->{absolute} = $args[0];
return $self;
}
return $self->{base};
lib/Astro/App/Satpass2/ParseTime.pm view on Meta::CPAN
This time is used (indirectly) when the parse identifies a relative
time.
When called without arguments, it behaves as an accessor, and returns
the current base time setting.
When called with at least one argument, it behaves as a mutator, sets
the base time, and returns the C<$pt> object to allow call chaining.
Subclasses B<may> override this method, but if they do so they B<must>
call C<SUPER::> with the same arguments they themselves were called
with, and return whatever C<SUPER::> returns.
=head2 config
use YAML;
print Dump ( $pt->config( changes => 1 );
This method retrieves the configuration of the formatter as an array of
array references. The first element of each array reference is a method
name, and the subsequent elements are arguments to that method. Calling
the given methods with the given arguments should reproduce the
lib/Astro/App/Satpass2/ParseTime.pm view on Meta::CPAN
the default configuration are reported.
=item decode
If this boolean argument is true (in the Perl sense), the
L<decode()|/decode> method is used to obtain the configuration values.
=back
Subclasses that add other ways to configure the object B<must> override
this method. The override B<must> call C<SUPER::config()>, and include
the result in the returned data.
=head2 delegate
my $delegate = $class->delegate()
This static method returns the name of the class to be instantiated.
Normally a subclass will return its own class name, but if there is more
than one possible wrapper for a given parser (e.g.
L<Date::Manip|Date::Manip>, which gets handled differently based on its
lib/Astro/App/Satpass2/ParseTime.pm view on Meta::CPAN
This method wraps other methods, converting their returned values to
human-readable. The arguments are the name of the method, and its
arguments if any. The return values of methods not explicitly documented
below are not modified.
There are currently no methods whose returns are affected by routing
them through C<decode>. This may change.
If a subclass overrides this method, the override should either perform
the decoding itself, or delegate to C<SUPER::decode>.
=head2 parse_time_absolute
$epoch_time = $pt->parse_time_absolute( $string );
This method parses an absolute time string. It returns seconds since the
epoch, or C<undef> on error.
This method B<must> be overridden by any subclass.
lib/Astro/App/Satpass2/ParseTime.pm view on Meta::CPAN
When called without arguments, it behaves as an accessor, and returns
the current perltime flag setting.
When called with at least one argument, it behaves as a mutator, sets
the perltime flag, and returns the C<$pt> object to allow call chaining.
This specific method simply records the C<perltime> setting.
Subclasses B<may> override this method, but if they do so they B<must>
call C<SUPER::> with the same arguments they themselves were called
with, and return whatever C<SUPER::> returns.
=head2 parse
defined( $epoch_time = $pt->parse( $string, $default ) )
or die "'$string' can not be parsed.";
This method parses a time, returning the resultant Perl time. If
C<$string> is C<undef> or C<''>, $default is returned, or C<undef> if
C<$default> is not specified. If C<$string> fails to parse, C<undef> is
returned.
lib/Astro/App/Satpass2/ParseTime.pm view on Meta::CPAN
=head2 use_perltime
$classname->use_perltime()
This static method returns true if the class uses the C<perltime>
mechanism, and false otherwise.
This specific class simply returns false.
Subclasses may override this method, but if they do they B<must not>
call C<SUPER::>.
=head2 tz
$pt->tz( 'EST5EDT' ); # Specify an explicit time zone
$pt->tz( undef ); # Specify the default time zone
$tz = $pt->tz(); # Find out what the time zone is
This method is both accessor and mutator for the object's time zone
setting. What can go here depends on the specific subclass in use.
When called without arguments, it behaves as an accessor, and returns
the current time zone setting.
When called with at least one argument, it behaves as a mutator, sets
the time zone, and returns the C<$pt> object to allow call chaining.
This specific method simply records the C<tz> setting.
Subclasses B<may> override this method, but if they do so they B<must>
call C<SUPER::> with the same arguments they themselves were called
with, and return whatever C<SUPER::> returns. Also, overrides B<must>
interpret an C<undef> argument as a request to set the default time
zone, not as an accessor call.
=head1 SUPPORT
Support is by the author. Please file bug reports at
L<https://rt.cpan.org/Public/Dist/Display.html?Name=Astro-App-Satpass2>,
L<https://github.com/trwyant/perl-Astro-App-Satpass2/issues>, or in
electronic mail to the author.
lib/Astro/App/Satpass2/ParseTime/Code.pm view on Meta::CPAN
use constant DUMMY => 'DUMMY';
# __arguments() is normally called as a subroutine, but it needs access
# to this namespace to figure out the options, so we just load this
# module and then call __arguments() as a static method.
require Astro::App::Satpass2;
sub attribute_names {
my ( $self ) = @_;
return ( $self->SUPER::attribute_names(), qw{ code } );
}
sub class_name_of_record {
my ( $self ) = @_;
my $code = $self->code();
ref $code
and $code = DUMMY;
return $code;
}
lib/Astro/App/Satpass2/ParseTime/Code.pm view on Meta::CPAN
sub parse_time_absolute {
my ( $self, $string ) = @_;
return $self->_call_code( parse => $string );
}
sub tz {
my ( $self, @args ) = @_;
@args
and $self->_call_code( tz => $args[0] );
return $self->SUPER::tz( @args );
}
sub use_perltime {
my ( $self ) = @_;
return $self->_call_code( 'use_perltime' );
}
sub _attr {
my ( $self ) = @_;
my $pkg = __PACKAGE__;
lib/Astro/App/Satpass2/ParseTime/Date/Manip.pm view on Meta::CPAN
use Astro::Coord::ECI::Utils 0.112 qw{ greg_time_gm };
our $VERSION = '0.056';
sub __class_name {
return __PACKAGE__;
}
sub attribute_names {
my ( $self ) = @_;
return ( $self->SUPER::attribute_names(), qw{ back_end station } );
}
sub delegate {
my $back_end;
defined ( $back_end = __date_manip_backend() )
or return $back_end;
return __PACKAGE__ . "::v$back_end";
}
{
lib/Astro/App/Satpass2/ParseTime/Date/Manip/v5.pm view on Meta::CPAN
}
sub perltime {
my ( $self, @args ) = @_;
$invalid and $self->wail( $invalid );
if ( @args ) {
my $zone = $args[0] ? 'GMT' : $self->tz();
$zone = defined $zone ? "TZ=$zone" : $default_zone;
Date_Init( $zone );
}
return $self->SUPER::perltime( @args );
}
sub use_perltime {
return 1;
}
sub tz {
my ( $self, @args ) = @_;
$invalid and $self->wail( $invalid );
if ( @args ) {
if ( $args[0] || looks_like_number( $args[0] ) ) {
$ENV{TZ} = $args[0]; ## no critic (RequireLocalizedPunctuationVars)
$self->perltime() or Date_Init( "TZ=$args[0]" );
} else {
delete $ENV{TZ};
$self->perltime() or Date_Init( $default_zone );
}
}
return $self->SUPER::tz( @args );
}
sub __set_back_end_location {
return;
};
1;
=head1 NAME
lib/Astro/App/Satpass2/ParseTime/Date/Manip/v6.pm view on Meta::CPAN
my ( $self, @args ) = @_;
$invalid and $self->wail( $invalid );
if ( @args ) {
my $zone = $args[0];
my $dm = $self->_get_dm_field( 'object' );
defined $zone and '' ne $zone
or $zone = $self->_get_dm_field( 'default_zone' );
_normalize_zone( $zone );
$dm->config( setdate => "zone,$zone" );
}
return $self->SUPER::tz( @args );
}
sub __back_end_validate {
my ( $self, $cls ) = @_;
$cls->can( 'parse' )
or $self->wail( "$cls does not have a parse() method" );
return;
}
sub __set_back_end_location {
lib/Astro/App/Satpass2/ParseTime/ISO8601.pm view on Meta::CPAN
looks_like_number SECSPERDAY greg_time_gm greg_time_local };
use parent qw{ Astro::App::Satpass2::ParseTime };
our $VERSION = '0.056';
my $package = __PACKAGE__;
sub attribute_names {
my ( $self ) = @_;
return ( $self->SUPER::attribute_names(), qw{ back_end } );
}
sub class_name_of_record {
my ( $self ) = @_;
return $self->__back_end_class_name_of_record(
$self->SUPER::class_name_of_record() );
}
my $zone_re = qr{ (?i: ( Z | UT | GMT ) |
( [+-] ) ( [0-9]{1,2} ) :? ( [0-9]{1,2} )? ) }smx;
sub delegate {
return __PACKAGE__;
}
{
lib/Astro/App/Satpass2/ParseTime/ISO8601.pm view on Meta::CPAN
sub tz {
my ( $self, @args ) = @_;
if ( @args ) {
if ( defined $args[0] && $args[0] ne '' ) {
$self->{$package}{tz} = [
$self->_interpret_zone( $args[0], 1 ) ];
} else {
delete $self->{$package}{tz};
}
}
return $self->SUPER::tz( @args );
}
sub __back_end_default {
my ( undef, $cls ) = @_; # Invocant ($self) unused
defined $cls
and return $cls;
return 'DateTime';
}
sub __back_end_validate {
lib/Astro/App/Satpass2/Utils.pm view on Meta::CPAN
C<new()>. Subsequent arguments are name/value pairs of arguments to
C<new()>.
If called with a single undefined argument, it specifies the default.
=head2 __back_end_class_name_of_record
sub class_name_of_record {
my ( $self ) = @_;
return $self->__back_end_class_name_of_record(
$self->SUPER::class_name_of_record() );
}
This mixin appends the C<back_end> information, if any, to the class
name of record. It is called this way because C<SUPER::> is resolved
with regard to the package it occurs in, not the package of the
invocant.
=head2 expand_tilde
$expansion = $self->expand_tilde( $file_name );
This mixin (so-called) performs tilde expansion on the argument,
returning the result. Arguments that do not begin with a tilde are
returned unmodified. In addition to the usual F<~/> and F<~user/>, we