Rose::...s::Time(3pm)
okay bestie, this is the Rose::...s::Time(3pm) page from User Contributed Perl Documentation β and it's giving very specific time-method energy. let's get into it π
β¨ NAME β¨
Rose::DB::Object::MakeMethods::Time β create time-related methods for Rose::DB::Object-derived objects. periodt.
π¦ SYNOPSIS π¦
bestie, here's the whole vibe β code kept verbatim, no cap:
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 πΈ
so Rose::DB::Object::MakeMethods::Time creates methods that deal with times, and it inherits from Rose::Object::MakeMethods. slay. peep the Rose::Object::MakeMethods documentation to learn about the interface. the method types this module provides are described below, bestie.
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. iykyk.
π οΈ METHODS TYPES π οΈ
okay, these are the method types, one by one, no skips π
π interval π
create get/set methods for interval (years, months, days, hours, minutes, seconds) attributes. obsessed.
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 eachDateTime::Durationobject created by this method will be set to the specified mode. otherwise, the"end_of_month"parameter will not be passed to theDateTime::Durationconstructor. valid modes are"wrap","limit", and"preserve". see the documentation forDateTime::Durationfor 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 to0.
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 theparse_intervalmethod of the object'sdbattribute. 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. no cap.
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. we love precision.
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 to0. the maximum value is9.
Interfaces
get_setβ creates a get/set method for a time attribute. when setting the attribute, the value is passed through theparse_timemethod of the object'sdbattribute. 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. literally.
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) β the icon who wrote this.
π 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. fr fr.
source/version + date tea: perl v5.40.1 Β· 2025-08-21 Β· Rose::...s::Time(3pm) β that's the whole page, bestie. mwah π
π¦ where this page comes from
- ubuntu resolute: librose-db-object-perl 1:0.822-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: librose-db-object-perl 1:0.822-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms