Jed Lund > DateTimeX-Mashup-Shiras-v0.30.4 > DateTimeX::Mashup::Shiras::Types

Download:
DateTimeX-Mashup-Shiras-v0.30.4.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: v0.30.4   Source  

NAME ^

DateTimeX::Mashup::Shiras::Types - Types for DateTimeX::Mashup::Shiras

SYNOPSIS ^

    #!perl
    package MyPackage;

    use Moose;
    use DateTimeX::Mashup::Shiras::Types qw(
        WeekDay
                WeekDayFromStr
    );
    
    has 'attribute_1' => (
            is  => 'ro',
            isa => WeekDay->plus_coercions( WeekDayFromStr ),
        );

DESCRIPTION ^

Shiras - A small subspecies of Moose found in the western United States (of America).

This is the custom type class that ships with the DateTimeX::Mashup::Shiras package. Wherever possible coersion failures are passed back to the type so type errors will be explained. The types are implemented using Type::Tiny.

Caveat utilitor

All type tests included with this package are considered to be the fixed definition of the types. Any definition not included in the testing is considered flexible.

This module uses Type::Tiny which can, in the background, use Type::Tiny::XS. While in general this is a good thing you will need to make sure that Type::Tiny::XS is version 0.010 or newer since the older ones didn't support the 'Optional' method.

Types

There are no included coercions with these types. Any coercion usage should be with ->plus_coercions from the list below.

WeekDay

Definition: integers ( 1 .. 7 )

Coercions: from a string. The type will try to qr//i match the passed string to an english name of the week.

DateTimeDate

Definition: a DateTime instance

Coercions

These are named coercions available for export by this module. For the coercions to work with the Type they must be added to the type via ->plus_coercions. To test the type and coercions together use the ->coerce or ->assert_coerce functions.

WeekDayFromStr

Definition: Takes a string that matches the full or any portion of the initial letters in an english weekday name and converts it to an integer (1..7) where 1 = Monday. The match is case independant (qr/$_/i).

DateTimeDateFromHashRef

Definition: This will take a HashRef and attempt to treat is as %$args for the function Datetime->new( %$args )

DateTimeDateFromArrayRef

Definition: this will take an ArrayRef and use up to the first three positions in the array as; [ $arg, $type, $time_zone ]. This is only used for passing numbers coded as excel or unix epochs to be converted to DateTime objects. The elements are used as follows.

$arg: this is expected to be a number that falls either in the Unix range or in the Microsoft Excel range.

$type: this is a way to force the interpretation of the number. The four possibilites are; excel, win_excel, apple_excel, or epoch. If epoch is called then the number is interpreted by DateTime::Format::Epoch and the global variable "$DateTimeX::Mashup::Shiras::Types::epochdt" will be used. A $type eq 'excel' setting will convert to the global variable "$DateTimeX::Mashup::Shiras::Types::excel_type". Then the value will be passed to DateTimeX::Format::Excel as the 'system_type' for interpretation by that program.

$time_zone: if a value is entered then after $arg is converted to a DateTime object the instance will have $dt->set_time_zone( $time_zone ) called on it.

DateTimeDateFromNum

Definition: This will check the number for 0 or 60 (microsoft issues), negative integers, and positive integers with more than 7 digits and read them as epoch (Nixy) dates. It will turn any positive integer or decimial with less than 7 leading digits into an excel date using DateTime::Format::Excel. All positive decimals with 7 or more digits will also be treated as excel dates. Negative decimals will fail.This will take a number and guess what type it is. The data is then handled the same as an ArrayRef.

DateTimeDateFromStr

Definition: This should be the final fall back check and it attempts to turn any String into a DateTime object with DateTime::Format::Flexible.

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 '#####'.

$DateTimeX::Mashup::Shiras::Types::epochdt

This variable holds a DateTime object set to; year => 1970, month => 1, day => 1. To be used by DateTime::Format::Epoch as the Epoch start. If you wish to change the epoch start change this variable. All changes are permanent until the next change.

$DateTimeX::Mashup::Shiras::Types::excel_type

This variable holds the default excel type for DateTimeX::Format::Excel. The default is 'win_excel'.

SUPPORT ^

github DateTimeX-Mashup-Shiras/issues

TODO ^

1. Add Log::Shiras debugging in exchange for Smart::Comments

* Get Log::Shiras CPAN ready first! (Some horrible deep recursion happens so far)

AUTHOR ^

Jed Lund

jandrew@cpan.org

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.

DEPENDANCIES ^

5.010 - (perl)

version

Type::Tiny

DateTime

DateTime::Format::Epoch - 0.013

DateTimeX::Format::Excel

DateTime::Format::Flexible

SEE ALSO ^

Time::Piece

DateTime::Format::Excel

MooseX::Types

Date::Parse

Date::Manip::Date

DateTimeX::Format

syntax highlighting: