[REBOL] Re: [date date! month month-bounds] MONTH-BOUNDS func design
From: gregg::pointillistic::com at: 29-Jan-2008 0:11
CR> I'd go for always... if leap-year? now [...]
That's my inclination as well, though not how I first did it a long
>>Starting today, what do you have to do to get a list of all dates in
>>the current month?
CR> That's why days-in-month is needed. It doesn't explain why you
CR> need the month-bounds block. If I had days-in-month, I'd do it
CR> something like this...
CR> today: now
CR> repeat day days-in-month today [today/day: day print today/date]
That lets you act on each day in a month and, yes, days-in-month is
good for that, but it doesn't *give you* a list of days. To do that,
you have to run that logic and collect the values yourself, every time
you want that list of dates.
CR> How would month-bounds inprove on that?
range month-bounds now
>>Or how do you compare a date to see if it was last month,
CR> Currently, like so...
CR> date: now date/month: date/month - 1
CR> if all [foo/year = date/year foo/month = date/month][...]
CR> I'm open to the idea that month-bounds would improve on that. How
CR> would it be used to do it?
find range last-month foo
Or like you did, but with more abstraction
all [foo >= first last-month foo <= last last-month]
And of course, helpers can help
between? first last-month last last-month foo
>>or in any given date range?
CR> How would month-bounds help you with that?
CR> I'd use...
CR> if all [date >= low-date date <= high-date][...]
Where we're leading is
in-range? last-month foo
in-bounds? last-month foo
People may recall my RANGE and BOUNDS funcs. With all the rich types
we have in REBOL, we don't have any span/range type(s). I haven't
campaigned hard, or successfully, for them, but I think there's a lot
of value in them. It they aren't built in, the next question is how
best to create them at the mezzanine level.
>>In the case of month-bounds, let's say a user can say "find me all the
>>files that were added/updated between x and y". Given dates, or just a
>>month name (files updated in jan-2008), we need the time detail to
CR> But only for the end of the month, since...
>>> 1-jan-2008 = 1-jan-2008/0:0:0
CR> == true
only for the end of the month
would be kind of critical to that kind
of query though, yes? :)