DateTi...t::ICal(3pm)

πŸ“¦
version 0.13 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

DateTime::Event::ICal β€” a Perl DateTime extension for computing rfc2445 recurrences. that's the whole vibe, she's a recurrence girlie πŸ¦‹


🌸 SYNOPSIS 🌸

use DateTime;
use DateTime::Event::ICal;

my $dt = DateTime->new( year   => 2000,
                        month  => 6,
                        day    => 20,
                      );

my $set = DateTime::Event::ICal->recur(
     dtstart => $dt,
     freq =>    'daily',
     bymonth => [ 10, 12 ],
     byhour =>  [ 10 ]
);

my $dt_next = $set->next( $dt );

my $dt_previous = $set->previous( $dt );

my $bool = $set->contains( $dt );

my @days = $set->as_list( start => $dt1, end => $dt2 );

my $iter = $set->iterator;

while ( my $dt = $iter->next ) {
    print ' ', $dt->datetime;
}

like… you build a DateTime, you ask for a recur, and the set it hands back will give you next, previous, contains, as_list, or an iterator to loop over. main character energy fr ✨


πŸŽ€ DESCRIPTION πŸŽ€

okay so here's the tea, bestie: this module gives you convenience methods that let you easily build DateTime::Set objects for rfc2445 style recurrences. it's giving "I don't wanna hand-roll recurrence math" and honestly? iconic. πŸ’…


πŸ¦‹ USAGE πŸ¦‹

✨ recur ✨

this method returns a DateTime::Set object representing the recurrence you asked for. obsessed.

my $set = DateTime::Event::ICal->recur( %args );

it takes parameters that correspond to the rule parts spelled out in section 4.3.10 of RFC 2445. and no, I'm not gonna rewrite that RFC here (imagine 😭) β€” you're encouraged to read that first if you actually want to understand what all these parameters represent. iykyk.

  • dtstart β€” a DateTime object, and it's the start date. heads up though: this datetime is not included in the recurrence, unless it satisfies the recurrence's rules. so a set can be used for creating exclusion rules (rfc2445 calls it "exrule"), which don't include dtstart. 🫢
  • until β€” a DateTime object that specifies the recurrence's end date. you can also spell it dtend.
  • count β€” a positive number indicating the total number of recurrences. giving both a count and an until parameter is pointless, though it is currently allowed. so like, you can, but why bestie 😭
  • freq β€” one of:
"yearly", "monthly", "weekly", "daily",
"hourly", "minutely", "secondly"

see the DateTime::Event::Recurrence documentation for more details on what these mean.

  • interval β€” the interval between recurrences. it's a multiplier for the value specified by freq, and it defaults to 1. so if you set a freq of yearly and an interval of 3, that means a recurrence that happens every three years. math is mathing ✨
  • wkst β€” week start day. this can be one of: mo, tu, we, th, fr, sa, su. the default is Monday (mo).
note: this parameter is not yet implemented 🫠
  • bysecond => [ list ], byminute => [ list ], byhour => [ list ] β€” this should be one or more positive numbers, specified as a scalar or array reference. each number represents a second/minute/hour.

see RFC 2445, section 4.3.10 for more details.

  • byday => [ list ] β€” this should be a scalar or array reference containing days of the week, specified as mo, tu, we, th, fr, sa, su.

the day of week may have a prefix:

"1tu",  # the first tuesday of month or year
"-2we"  # the second to last wednesday of month or year

see RFC 2445, section 4.3.10 for more details.

  • bymonthday => [ list ], byyearday => [ list ] β€” a scalar or array reference containing positive or negative numbers, but not zero. for bymonthday, the allowed ranges are -31 to -1. for byyearday, the allowed ranges are -366 to -1, and 1 to 366.

day -1 is the last day of month or year.

see RFC 2445, section 4.3.10 for more details.

  • byweekno => [ list ] β€” a scalar or array reference containing positive or negative numbers, but not zero. the allowed ranges are -53 to -1, and 1 to 53.

the first week of year is week 1.

the default week start day is Monday.

week -1 is the last week of year.

see RFC 2445, section 4.3.10 for more details.

  • bymonth => [ list ] β€” a scalar or array reference containing positive or negative numbers, from -12 to -1 and 1 to 12.

month -1 is December. (so yeah, counting backwards from the end of the year, cute right 🌈)

see RFC 2445, section 4.3.10 for more details.

  • bysetpos => [ list ] β€” this can be either a scalar or an array reference of positive and negative numbers from -366 to -1, and 1 to 366. this parameter is used in conjunction with one of the other by... parameters.

see RFC 2445, section 4.3.10 for more details.


πŸ‘‘ AUTHOR πŸ‘‘

Flavio Soibelmann Glock fglock@gmail.com β€” the literal icon who wrote this πŸ’œ


🌟 CREDITS 🌟

the API was developed with help from the people in the datetime@perl.org list. group project that actually ate, we love to see it 🫢


Copyright (c) 2003 Flavio Soibelmann Glock. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.


🧚 SEE ALSO 🧚

  • datetime@perl.org mailing list
  • DateTime Web page <http://datetime.perl.org/>
  • The DateTime module.
  • DateTime::Event::Recurrence β€” simple rule-based recurrences.
  • DateTime::Format::ICal β€” can parse rfc2445 recurrences.
  • DateTime::Set β€” recurrences defined by callback subroutines.
  • DateTime::Event::Cron β€” recurrences defined by "cron" rules.
  • DateTime::SpanSet
  • RFC2445 <http://www.ietf.org/rfc/rfc2445.txt> β€” Internet Calendaring and Scheduling Core Object Specification.

and that's the whole page bestie πŸ’– this one's living in perl v5.34.0, dated 2022-06-13 β€” go forth and recur, you absolute DateTime::Event::ICal(3pm) legend πŸŒˆβ­πŸŽ€

πŸ“¦ where this page comes from