Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I'd probably be willing to put set_day_of_week into DateTime.pm proper. I don't know about the sugar methods though.

    Regardless, DateTime::Weekdays probably isn't the right namespace. Please come discuss this on the datetime@perl.org list.
    • I know this is not the proper venue – I saw the pointer to the mailing list. I posted here instead of to the list because, well, I’d have to subscribe to the list, and then I’d be subscribed to yet another Perl list. I am on way too many of those already… I guess I should consolidate the mailboxes for the low-traffic lists and suck it up.

      Also, I know it’s not a good name. Don’t worry, I’m not putting this on CPAN quite yet. :-) That’s why I posted an RFC.

      I also don’t think the names for the sugar methods are particularly great. But if they don’t go in at all, then both the workhorse method and its parameters should have shorter names.

      Mainly, I’d like these kinds of calculations to result in sufficiently similar amounts of code as the use of Date::Manip would yield that one would not be overly inclined to reach for Date::Manip over DateTime even in quick and dirty scripts like my “pipe this 10-line mail to sendmail” 15-liner cron job. The sugar methods seem necessary to achieve that.

      • I think set_day_of_week is a bad name and doesn't belong in the core of DateTime. The name doesn't really uniquely identify what the method does and implies several different inconsistent possibilities for its semantics.

        I think it'd be better if this functionality were wrapped in a DateTime::Set, which would give you the next and previous methods you are looking for. Maybe DateTime::Set::ByWeekday?

        --
        J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
        • That sounds reasonable; I’m just not sure it makes sense. There is nothing of interest about the set as a whole: it’s no more than a set with weekly recurrence (and you can easily construct it that way if you do need such a set). The only property of interest is that 2 (or 3) specific members of the set are closest to a particular date.

          Also, I wanted to roll in a way to find the passed weekday that falls within the same week as the given date. To me there seems to be no reasonable way to conce