06.28.10

Sunrise/Sunset Onebox

Posted in astronomy, personal, web at 6:45 pm by danvk

If you try searching for [sunrise san francisco] on Google, you’ll see a special display in the results:

This is known as a “onebox”. It’s designed to get you answers quickly. Other examples include the calculator (e.g. [2*2]), weather ([weather 94110]) and time ([time italy]) oneboxes.

The sunrise/sunset onebox is a project that I worked on in my spare time and recently launched. You can read more about it on the Official Google Blog. I first had the idea for this onebox about two years ago, so it’s very gratifying to see it finally launch!

A few features which are worth calling out:

  • The sunrise and sunset times are calculated when you perform your query. They are a function of latitude, longitude and the current time. The algorithm is based on the one used by NOAA.
  • In most places, you can just search for [sunrise] or [sunset] to get results for your current location. Google figures this out based on your IP.
  • This onebox works on mobile phones, too, so you can search for sunset times when you’re out on a hike.

There’s a wrinkle to the sunrise/sunset calculation that non-astronomers don’t typically think about. The sun starts to behave strangely once you get north of the arctic circle or south of the antarctic circle. If you’re north of the arctic circle, then there will be at least one day during the summer when the site never sets. And there will be at least one day during the winter when it never rises. This is truly a special case for the onebox! Here’s what it looks like:

I feel bad for those Barrowans — hopefully they’ll be able to fall asleep sometime in the next 34 days!

3 Comments

  1. Greg Grothaus said,

    July 1, 2010 at 12:59 pm

    I was actually in Barrow during one of the no-sunset periods 2 years ago. I wasn’t even there 24 hours, but from talking to folks, they aren’t at all upset about this period. The snow is mostly melted, the weather is nice, the only problem is that the roads are really muddy. The month of no sun though seems very painful. It’s cool that the onebox considered this case!

  2. almaz said,

    July 7, 2010 at 5:19 am

    please check you e-mail
    thx

  3. Brant said,

    August 26, 2011 at 6:50 pm

    Every week or so, I’ll find myself wondering if I how much longer I can squeeze in at work before riding home without having to do it in the dark. For a long time, I’d search for “sf sunset”, click through to TimeAndDate.com’s table, find today, mkay. Then one day… BLAM. A lovely little one box with not only the time o’ the clock but relative as well.

    I never imagined I’d have the chance to thank the creator, but checked out your blog to find out a little bit about the creator of Old SF, which is another level of awesome.

    So thanks a bunch for the little bit of joy and convenience that is your sunset/rise one box, Dan. Nice work!