DateTimeX::Mashup::Shiras
A Moose role with four date attributes
SYNOPSIS
package MyPackage;
use Moose;
use MooseX::HasDefaults::RO;
with 'DateTimeX::Mashup::Shiras';
no Moose;
__PACKAGE__->meta->make_immutable;
#!perl
my $firstinst = MyPackage->new(
'date_one' => '8/26/00',
);
print $firstinst->get_date_one->format_cldr( "yyyy-MMMM-d" ) . "\n";
print $firstinst->get_date_one_wkend->ymd( '' ) . "\n";
print $firstinst->get_date_one_wkstart->ymd( '' ) . "\n";
print $firstinst->set_date_three( '11-September-2001' ) . "\n";
print $firstinst->get_date_three_wkstart->dmy( '' ) . "\n";
print $firstinst->set_date_one( -1299767400 ) . "\n";
print $firstinst->set_date_one( 36764.54167 ) . "\n";
print $firstinst->set_date_one( 0 ) . "\n";
print $firstinst->set_date_one( 60 ) . "\n";
#######################################
# Output of SYNOPSIS
# 01:2000-August-26
# 02:20000901
# 03:20000826
# 04:2001-09-11T00:00:00
# 05:08092001
# 06:1928-10-26T09:30:00
# 07:2000-08-26T13:00:00
# 09:1970-01-01T00:00:00
# 09:1970-01-01T00:01:00
#######################################
DESCRIPTION
Shiras - A small subspecies of Moose found in the western United States.
This is a Moose Role (Moose::Manual::Roles) that has four flexible date attributes and some additional date functionality. This role can add some date attributes to your class with built in date handling. It also provides the traditional today, now, and weekend date calculation for a given day.
The flexibility of input for the dates comes from three different DateTime::Format packages using type coersion. The three modules are; DateTime::Format::Flexible. DateTime::Format::Epoch, and DateTimeX::Format::Excel. The choice between them is managed by DateTimeX::Mashup::Shiras::Types as a type coersion. This means that all input strings are parsed by ::Format::Flexible. All numbers are parsed either by ::Format::Excel or by ::Format::Epoch. See the type package for the details and corner cases. Since all the succesful date 'getters' return DateTime objects, all the DateTime methods can be applied directly. ex. $inst->get_today_wkend->ymd( "/" ).
Attributes
Attributes listed here can be passed to ->new as listed below.
(date_one|date_two|date_three|date_four)
Definition: these are date attributes set to the type 'datetimedate'. See the Type Class for more details.
Default empty
Range epoch numbers, DateTime definition HashRefs, Date Epoch ArrayRefs, and human readable strings
week_end
Definition: This holds the definition of the last day of the week
Default 'Friday'
Range This will accept either day names, day abbreviations (no periods), or day integers (1 = Monday, 7 = Sunday )
Methods
Methods are used to manipulate both the public and private attributes of this role. All attributes are set as 'ro' so other than ->new( ) these methods are the only way to change or clear attributes. See Moose::Manual::Roles for generic implementation instructions.
set_(date_one|date_two|date_three|date_four)( $date )
Definition: This is the way to change (or set) the various dates.
Accepts: Any $date data that can be coerced by supported ::Format modules.
Returns: the equivalent DateTime object
get_(date_one|date_two|date_three|date_four|today|now)->format_command( 'format' )
Definition: This is how you can call various dates and format their output. example $self->get_date_two->ymd( "-" ). For this example the date_two attribute had been previously set. Note: 'today' and 'now' are special attribute cases and do not need to be defined to be retrieved.
Returns: a DateTime object
get_(date_one|date_two|date_three|date_four|today)_(wkend|wkstart)
Definition: This is a way to call the equivalent start and end of the week definded by the given 'week_end' attribute value. 'now' is not included in this list.
Returns: a DateTime object
GLOBAL VARIABLES
$ENV{Smart_Comments}
The module uses Smart::Comments if the '-ENV' option is set. The 'use' is encapsulated in an if block triggered by an environmental variable to comfort non-believers. Setting the variable $ENV{Smart_Comments} in a BEGIN block will load and turn on smart comment reporting. There are three levels of 'Smartness' available in this module '###', '####', and '#####'.
SUPPORT
github DateTimeX-Mashup-Shiras/issues
TODO
1. Add Log::Shiras debugging in exchange for Smart::Comments
* Get Log::Shiras CPAN ready first (Still some deep recursion issues)
AUTHOR
COPYRIGHT
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
This software is copyrighted (c) 2013, 2014 by Jed Lund.
DEPENDENCIES
5.010 - (perl)
DateTimeX::Mashup::Shiras::Types
includes depenencies to
SEE ALSO
Build/Install from Source
1. Download a compressed file with the code
2. Extract the code from the compressed file. If you are using tar this should work:
tar -zxvf DateTimeX-Mashup-Shiras-v0.xx.tar.gz
3. Change (cd) into the extracted directory
(For Windows find what version of make was used to compile your perl)
perl -V:make
Then (for Windows substitute the correct make function (s/make/dmake/g)?)
>perl Makefile.PL
>make
>make test
>make install # As sudo/root
>make clean