Extending Google Calendar with a Chrome Extension

Some would say I am obsessed with Google Calendar (henceforth known as The Calendar.) Or, ironically, that I have “too much free time.” I track every half hour-sized activity from work tasks and social outing to my ideal amount of sleep.

Something it didn’t have? Enough extensions from Google Labs. As far as I could tell, these additions haven’t changed much since Google Calendar first debuted. What I truly wanted to see was some color highlighting to indicate when daylight hours were. As it turns out, the best way to get this feature was to write it myself with a Chrome extension.

The result is the free Chrome extension Daylight for Google Calendar.

Busy calendar
Addicted 2 events… seriously… this is a cry for help.


When I worked my Bigco job back in Virginia, my job-home was a windowless office. In the winter, I’d often arrive before the sun came up and leave well after the sun went down. Depressing. Every day I would look up the sunrise and sunset times for my location and create a calendar event in The Calendar so that I could make sure I had an outside activity during daylight hours.


This extension does that for you. After installing the extension, The Calendar will determine your location using built-in browser magic and highlight the hours from sunrise to sunset for each day in an unobtrusive and intuitive light yellow.

Sunrise/sunset calculations

After you know the datetime and location, you need some way of computing the sunrise and sunset times. I defer this complexity to Vladimir Agafonkin’s suncalc JavaScript library. (BSD license)

Source code

There’s a fair amount of scraping required to get the date information for each day. Hopefully, if Google ever restyles The Calendar, the structural stuff will remain the same.

For more information on creating a Chrome extension, I highly recommend justjs.com’s article Chrome extensions: how to enhance Google Calendar and other web apps.

If you’re curious about how the extension it works, check out the source code on GitHub. Please steal! (MIT license)

masyukun Written by:

Software engineer consultant.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.