Module:...Interval(3)
π 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::GenericModule::Generic::DateTimeDateTimeDateTime::Format::StrptimeDateTime::TimeZone
like, go read those too. iykyk. π
π AUTHOR π
Jacques Deguest <jack@deguest.jp>
π COPYRIGHT & LICENSE π
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
- alpine 3.24: perl-module-generic-doc 1.1.3-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms