9 package # hide me from PAUSE
15 sub minutes { $_[0] * 60 }
16 sub hours { $_[0] * 60->minutes }
17 sub days { $_[0] * 24->hours }
18 sub weeks { $_[0] * 7->days }
19 sub years { $_[0] * 365->days }
20 sub centuries { $_[0] * 10->years }
23 my ($self, $time) = @_;
29 my ($self, $time) = @_;
44 *century = \¢uries;
50 sub as_string { scalar localtime $_[0] }
54 Moose::Autobox->mixin_additional_role(SCALAR => 'Units::Time');
58 print "2 days ago was : " . 2->days->ago->as_string;
59 print "3 weeks from now will be : " . 3->weeks->from_now->as_string;
60 my $one_week_ago = 1->week->ago;
61 print "1 day until 1 week ago : " . 1->day->til($one_week_ago)->as_string;
62 print "2 years since 1 week ago : " . 2->years->since($one_week_ago)->as_string;
72 Moose::Autobox->mixin_additional_role(SCALAR => 'Units::Time');
74 print "2 days ago was : " . 2->days->ago->as_string;
75 print "3 weeks from now will be : " . 3->weeks->from_now->as_string;
76 print "1 day until 1 week ago : " . 1->day->til(1->week->ago)->as_string;
77 print "2 years since 1 week ago : " . 2->years->since(1->week->ago)->as_string;
81 This is a Moose::Autobox port of the perl6 vmethods example.
85 Stevan Little, E<lt>stevan@iinteractive.comE<gt>
87 =head1 ACKNOLEDGEMENTS
89 This code was ported from the version in the Pugs
90 examples/vmethods/ directory. See that for original author