On 3/11/07, BJörn Lindqvist <[EMAIL PROTECTED]> wrote:
> I do not really understand proper temporal intervals. But I am
> interested what "temporal interval logic" has to say about this
> problem:
>
> def get_most_recent_articles(articles, cutoff_date):
>     recent_articles = []
>     for article in articles:
>         if article.datetime_posted > cutoff_date:
>             recent_articles.append(article)
>     return recent_articles

Thanks for being concrete here. =)

> Would temporal interval logic make it so an article with
> datetime(2007, 1, 1, 0, 0, 0) be included, if cutoff_date was
> date(2007, 1, 1)?

No, datetime(2007, 1, 1, 0, 0, 0) is not *after* date(2007, 1, 1), it
is *included* within it.  If you want an article with that datetime to
be included, you should be comparing against datetime(2006, 12, 31,
23, 59, 59) or date(2006, 12, 31).

> What about articles with datetimes (2007, 1, 1, 0, 0, 1)

No. For the same reason as above.

> and (2007, 1, 2, 0, 0, 0) respectively?

Yes.

> I believe that "temporal interval logic" has to include at least
> the last two examples in recent_articles, otherwise it would
> be highly annoying.

Could you elaborate?  Right now, to get the results you want with your
code, you have to compare against datetime(2006, 12, 31, 23, 59, 59).
How is comparing against date(2006, 12, 31) any worse?

Steve
-- 
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
        --- Bucky Katt, Get Fuzzy
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to