Wednesday, May 04, 2005

google date range hack

Update: Google's daterange functionality comes and goes. Right now it goes. :/ What's a brother to do?


It seems like every time I think of some cool feature that I wish Google had, I go check out the Google Cheat Sheet, the advanced operators page, or Section 2.2 of their API reference and I find that lo, they've already implemented it. The ability to filter out 99% of the results and home in on pages I actually wanted to find is great, and most of the operators are fairly intuitive in their application.

With one notable exception: the daterange: operator. Like it sounds, this operator restricts results to those that are between two dates, which is very useful for finding posts related to events in the world outside. The only problem is that the dates must be Julian dates... a computer's-eye view of what the date would be if we still used the Julian calendar. Now this probably makes a lot of sense in terms of search algorithms and Google's file-system, but for humans it's a pain in the ass.

To make this feature easier to use I've written a greasemonkey script for Firefox that injects little calendars into Google's main page. This hack calculates the Julian dates on-the-fly as you click on the calendar, and updates the query string as necessary. Some notes:
  • The initial search interval is set to one year ago.
  • The two calendars are marked "From:" and "To:", but the script will order the query terms correctly regardless of which one is later.
  • I don't check for dates in the future... if you really just can't wait to find out what's going to happen in the future, knock yourself out. Just don't come crying to me if you get busted for looking up the answers to next month's midterms.
  • Similarly if you have the urge to restrict the search to documents that were published in the middle ages, go for it. The only constraint is that you'd be clicking the little arrows like a crackmonkey for hours.
  • The script only injects the calendars on the Google front page. The menu is a moving target on pages that have remarkably few id and class attributes, and I didn't feel like chasing the little bugger down.
  • Like all greasemonkey scripts, this one only works if you have javascript on.

If you improve on this script, have a recommendation, or want to complain about something, please leave a comment on this post.



Anonymous Anonymous said...

I like the idea, but I wouldn't be using that with every search... maybe once a week. Can you place the calenders vertically on the right hand side of the screen ?

I wish I knew a little more about java/html/etc, i would add this myself but :(

Blogger Foobario said...

The calendars don't show up at all by default; there's just an item added to the menu just right of the input field. Selecting that item makes the calendars appear.
  Post a Comment
return to front page