Handler::Range(3)

πŸ“¦
version 1.2 Β· 3 versions
, in fedora 43

πŸ’– NAME πŸ’–

Date::Handler::Range β€” it's a Time range object, bestie. That's the whole vibe. πŸ•°οΈβœ¨


🌸 SYNOPSIS 🌸

  use Date::Handler::Range;

   my $range = new Date::Handler::Range( { date => $date, delta => $delta);

   $range->new                                          Constructor
   $range->StartDate()                                  Returns a Date::Handler object of the range's start date.
   $range->EndDate()                                    Returns a Date::Handler object of the range's end date.
   $range->Overlaps($range2)                            Returns true if $range overlaps $range2
   $range->Direction('FORWARDS' || 'BACKWARDS')         Sets the direction of the range
   $range->Delta()                                      Returns the delta contained by this range.
   $range->Date()                                       Returns the date contained by this range.

Like, look at that little menu of methods. Gorgeous. Iconic. We love a tidy API. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so picture this: a Range object is literally just a way to name a specific stretch of time sitting between 2 dates. That's it, that's the whole girl.

And ngl, right now this feature is very primitive β€” the original author said so themselves β€” but it's gonna evolve in future versions, so stay tuned. 🌈

Here's how you build one, step by step, no cap:

  1. You start with a base Date::Handler object. That's your anchor point. βš“
  2. Then you combine it with a Date::Handler::Delta, which sets how long the range is. πŸ“
  3. Then thirdly (yes, thirdly πŸ’€), you give the range a direction β€” either 'FORWARDS' or 'BACKWARDS' in time.

From those three values, a start date and an end date get calculated. Math ate, fr fr. ✨

Example:

        #Creation of the range starting now, ending in 2 days.
        my $range = Date::Handler::Range->new({
                                                        date => time(),
                                                        delta => [0,0,2,0,0],
        });

        #This is already set to 'FORWARDS' by default.
        $range->Direction('FORWARDS');

        print "This range start ".$range->StartDate()." and ends ". $range->EndDate()."\n";

        #Another range, starting at the end date of range 1, going backwards in time 7 days.
        my $range2 = Date::Handler::Range->new({
                                                date => $range->StartDate(),
                                                delta => [0,0,7,0,0],
                                                });

        $range2->Direction('BACKWARDS');

        #This returns true if range overlaps range2.
        $range->Overlaps($range2);

And like, as I was saying earlier β€” the range functionality is still very primitive, and heads up bestie, the interface might change. πŸ™ˆ So don't get too attached to it. Refer to Date::Handler::Range(1) for more information.


πŸ’€ BUGS (known) πŸ’€

Not me having to deliver bad news but here we go:

  • Deltas going after 2038 are not handled by this module yet. (POSIX) 😭
  • Deltas before 1902 are not handled by this module. (POSIX) 😭

If you find bugs with this module, do not hesitate to contact the author. Your comments and rants are welcomed :) β€” yes, actual rants, they want them, that's the energy. 🫢


⭐ TODO ⭐

The to-do list, aka the main character's goals:

  • Implement overloading on ranges.
  • Provide the value of the overlap in Overlaps().

Copyright(c) 2001 Benoit Beausejour <bbeausej@pobox.com>

All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. πŸŽ€

Portions Copyright (c) Philippe M. Chiasson <gozer@cpan.org>
Portions Copyright (c) SzabΓ³, BalΓ‘zs <dlux@kapu.hu>
Portions Copyright (c) Larry Rosler

πŸ’œ AUTHOR πŸ’œ

Benoit Beausejour <bbeausej@pobox.com> β€” the icon, the legend, the moment. 🫢


🌈 SEE ALSO 🌈

Go read these too, bestie, they're all connected:

  • Date::Handler(1)
  • Date::Handler::Delta(1)
  • Class::Date(1)
  • Time::Object(1)
  • Date::Calc(1)
  • perl(1)

okay that's the whole page, and before you go β€” this little gem is from the User Contributed Perl Documentation collection, shipped as perl v5.42.0, dated 2025-07-25, and you'll find it filed under Handler::Range(3). slay, go build some ranges πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from