Provided by: librose-db-object-perl_0.815-1_all bug

NAME

       Rose::DB::Object::MakeMethods::Time - Create time-related methods for Rose::DB::Object-derived objects.

SYNOPSIS

           package MyDBObject;

           use base 'Rose::DB::Object';

           use Rose::DB::Object::MakeMethods::Time
           (
             interval =>
             [
               t1 => { scale => 6 },
               t2 => { default => '3 days 6 minutes 5 seconds' },
             ],

             time =>
             [
               start => { scale => 5 },
               end   => { default => '12:34:56' },
             ],
           );

           ...

           $o->t1('5 minutes 0.003 seconds');

           $dt_dur = $o->t1; # DateTime::Duration object

           print $o->t1->minutes;    # 5
           print $o->t1->nanosecond; # 3000000

           $o->start('12:34:56.12345');

           print $o->start->nanosecond; # 123450000
           print $o->start->as_string;  # 12:34:56.12345

           $o->end('6pm');

           $tc = $o->end; # Time::Clock object

           print $o->end->hour; # 18
           print $o->end->ampm; # PM

           print $o->end->format('%I:%M %p'); # 6:00 PM
           $o->end->add(hours => 1);
           print $o->end->format('%I:%M %p'); # 7:00 PM

DESCRIPTION

       "Rose::DB::Object::MakeMethods::Time" creates methods that deal with times, and inherits from
       Rose::Object::MakeMethods.  See the Rose::Object::MakeMethods documentation to learn about the interface.
       The method types provided by this module are described below.

       All method types defined by this module are designed to work with objects that are subclasses of (or
       otherwise conform to the interface of) Rose::DB::Object.  In particular, the object is expected to have a
       db method that returns a Rose::DB-derived object.  See the Rose::DB::Object documentation for more
       details.

METHODS TYPES

       interval
           Create get/set methods for interval (years, months, days, hours, minutes, seconds) attributes.

           Options
               "default"
                   Determines the default value of the attribute.

               "end_of_month_mode"
                   This mode determines how math is done on duration objects.  If defined, the "end_of_month"
                   setting for each DateTime::Duration object created by this method will be set to the
                   specified mode.  Otherwise, the "end_of_month" parameter will not be passed to the
                   DateTime::Duration constructor.

                   Valid modes are "wrap", "limit", and "preserve".  See the documentation for
                   DateTime::Duration for a full explanation.

               "hash_key"
                   The key inside the hash-based object to use for the storage of this attribute.  Defaults to
                   the name of the method.

               "interface"
                   Choose the interface.  The default is "get_set".

               "scale"
                   An integer number of places past the decimal point preserved for fractional seconds.
                   Defaults to 0.

           Interfaces
               "get_set"
                   Creates a get/set method for a interval (years, months, days, hours, minutes, seconds)
                   attribute.  When setting the attribute, the value is passed through the parse_interval method
                   of the object's db attribute.  If that fails, a fatal error will occur.

                   When saving to the database, the method will pass the attribute value through the
                   format_interval method of the object's db attribute before returning it.

                   This method is designed to allow interval values to make a round trip from and back into the
                   database without ever being "inflated" into DateTime::Duration objects.  Any use of the
                   attribute (get or set) outside the context of loading from or saving to the database will
                   cause the value to be "inflated" using the  parse_interval method of the object's db
                   attribute.

               "get"
                   Creates an accessor method for a interval (years, months, days, hours, minutes, seconds)
                   attribute.  This method behaves like the "get_set" method, except that the value cannot be
                   set.

               "set"
                   Creates a mutator method for a interval (years, months, days, hours, minutes, seconds)
                   attribute.  This method behaves like the "get_set" method, except that a fatal error will
                   occur if no arguments are passed.

           Example:

               package MyDBObject;

               use base 'Rose::DB::Object';

               use Rose::DB::Object::MakeMethods::Time
               (
                 time =>
                 [
                   't1' => { scale => 6 },
                   't2' => { default => '3 days 6 minutes 5 seconds' },
                 ],
               );

               ...

               $o->t1('5 minutes 0.003 seconds');

               $dt_dur = $o->t1; # DateTime::Duration object

               print $o->t1->minutes;    # 5
               print $o->t1->nanosecond; # 3000000

       time
           Create get/set methods for time (hours, minutes, seconds) attributes.  Fractional seconds up to
           nanosecond precision are supported.

           Options
               "default"
                   Determines the default value of the attribute.

               "hash_key"
                   The key inside the hash-based object to use for the storage of this attribute.  Defaults to
                   the name of the method.

               "interface"
                   Choose the interface.  The default is "get_set".

               "scale"
                   An integer number of places past the decimal point preserved for fractional seconds.
                   Defaults to 0.  The maximum value is 9.

           Interfaces
               "get_set"
                   Creates a get/set method for a time attribute.  When setting the attribute, the value is
                   passed through the parse_time method of the object's db attribute.  If that fails, a fatal
                   error will occur.

                   When saving to the database, the method will pass the attribute value through the format_time
                   method of the object's db attribute before returning it.

                   This method is designed to allow time values to make a round trip from and back into the
                   database without ever being "inflated" into Time::Clock objects.  Any use of the attribute
                   (get or set) outside the context of loading from or saving to the database will cause the
                   value to be "inflated" using the  parse_time method of the object's db attribute.

               "get"
                   Creates an accessor method for a time attribute.  This method behaves like the "get_set"
                   method, except that the value cannot be set.

               "set"
                   Creates a mutator method for a time attribute.  This method behaves like the "get_set"
                   method, except that a fatal error will occur if no arguments are passed.

           Example:

               package MyDBObject;

               use base 'Rose::DB::Object';

               use Rose::DB::Object::MakeMethods::Time
               (
                 time =>
                 [
                   start => { scale => 5 },
                   end   => { default => '12:34:56' },
                 ],
               );

               ...

               $o->start('12:34:56.12345');

               print $o->start->nanosecond; # 123450000
               print $o->start->as_string;  # 12:34:56.12345

               $o->end('6pm');

               $tc = $o->end; # Time::Clock object

               print $o->end->hour; # 18
               print $o->end->ampm; # PM

               print $o->end->format('%I:%M %p'); # 6:00 PM
               $o->end->add(hours => 1);
               print $o->end->format('%I:%M %p'); # 7:00 PM

AUTHOR

       John C. Siracusa (siracusa@gmail.com)

LICENSE

       Copyright (c) 2010 by John C. Siracusa.  All rights reserved.  This program is free software; you can
       redistribute it and/or modify it under the same terms as Perl itself.