Module:...Interval(3)

πŸ“¦ version 1.1.3, in alpine 3.24

πŸ’– Module::Generic::DateTime::Interval β€” the perl manual, but make it make sense πŸ’–

okay so bestie, this is one of those User Contributed Perl Documentation pages, and it's about a datetime interval thingy. stay with me, it's actually cute.


✨ NAME ✨

Module::Generic::DateTime::Interval β€” an Enhanced DateTime::Duration Object. like, it's giving glow-up. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the vibe, literally copy-paste ready:

use Module::Generic::DateTime::Interval;
my $int = Module::Generic::DateTime::Interval->new( $duration );
# Inspect by returning a formatted string showing year, month, etc
print( $int->dump, "\n" );
$int->days = 10;
my $days = $int->days;
$int->hours = 10;
my $hours = $int->hours;
$int->minutes = 10;
my $minutes = $int->minutes;
$int->months = 10;
my $months = $int->months;
$int->nanoseconds = 10;
my $nano = $int->nanoseconds;
$int->seconds = 10;
my $seconds = $int->seconds;
$int->weeks = 10;
my $weeks = $int->weeks;
$int->years = 10;
my $years = $int->years;

my $dt = DateTime->now;
my $dt2 = DateTime->now->add( days => 10 );
# Get an Module::Generic::DateTime::Interval object
my $int = $dt2 - $dt;
print $int->days, "\n"; # 10

see that last bit? you literally just subtract two datetimes and boom πŸ’₯ you get an interval object. main character math.


🌸 DESCRIPTION 🌸

okay so Module::Generic::DateTime::Interval is a thin wrapper around DateTime::Duration that adds enhanced features. every other regular method call that belongs to DateTime::Duration gets passed straight through to it via AUTOLOAD. so you're not losing anything, you're just gaining ✨extras✨.

this interval object is overloaded, which means it lets you do these operations on it:

  • "+"
  • "-"
  • "*"
  • "comparison"

periodt. 🫢


πŸŽ€ METHODS πŸŽ€

🌈 days

this is an lvalue method to set or get the number of days in this interval object.

example:

$int->days = 10;
$int->days( 10 );
my $days = $int->days;

🌈 hours

this is an lvalue method to set or get the number of hours in this interval object.

example:

$int->hours = 10;
$int->hours( 10 );
my $hours = $int->hours;

🌈 minutes

this is an lvalue method to set or get the number of minutes in this interval object.

example:

$int->minutes = 10;
$int->minutes( 10 );
my $minutes = $int->minutes;

🌈 months

this is an lvalue method to set or get the number of months in this interval object.

example:

$int->months = 10;
$int->months( 10 );
my $months = $int->months;

🌈 nanoseconds

this is an lvalue method to set or get the nanoseconds of days in this interval object.

example:

$int->nanoseconds = 10;
$int->nanoseconds( 10 );
my $nanoseconds = $int->nanoseconds;

🌈 seconds

this is an lvalue method to set or get the seconds of days in this interval object.

example:

$int->seconds = 10;
$int->seconds( 10 );
my $seconds = $int->seconds;

🌈 weeks

this is an lvalue method to set or get the weeks of days in this interval object.

example:

$int->weeks = 10;
$int->weeks( 10 );
my $weeks = $int->weeks;

🌈 years

this is an lvalue method to set or get the years of days in this interval object.

example:

$int->years = 10;
$int->years( 10 );
my $years = $int->years;

🧚 SERIALISATION 🧚

serialisation by CBOR, Sereal and Storable is supported by this package. to make that happen, the following subroutines are implemented: "FREEZE", "THAW", "STORABLE_freeze" and "STORABLE_thaw". slay. πŸ‘‘

πŸ’œ Thread Safety

this module is thread-safe. no cap.

instances of "Module::Generic::DateTime" and "Module::Generic::DateTime::Interval" are immutable once created and do not share any mutable state across threads. so yeah, go wild with your threads, bestie. 🧡✨


⭐ SEE ALSO ⭐

  • Module::Generic
  • Module::Generic::DateTime
  • DateTime
  • DateTime::Format::Strptime
  • DateTime::TimeZone

like, go read those too. iykyk. πŸ“š


πŸ‘‘ AUTHOR πŸ‘‘

Jacques Deguest <jack@deguest.jp>


Copyright (c) 2000-2024 DEGUEST Pte. Ltd.

you can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself. πŸ“


and that's the whole page, bestie β€” no notes πŸ™ˆ

πŸ’– cute little sign-off before you close the tab: this was perl v5.42.2, dated 2026-02-15, filed under Module:...Interval(3). take care of her, she's iconic. πŸŽ€βœ¨
πŸ“¦ where this page comes from