Displaying Energimolnet data to the user

Today I wanted to discuss how we work with timezones in our client applications. You may have noticed that we’ve discussed timezones here before; I wanted to write about it again because it is really the only slightly complex part of working with our API.

The confusing aspect is that the Swedish electricity industry assumes all meters are in GMT+1 (normal or winter time in Sweden) throughout the year.  That means that your bills, the data from meters and even Energimolnet’s data is skewed during summer time.

Summer time vs. normal time

The image below shows how we receive data during winter/normal time. The yellow is the window of time that makes up an electricity industry day. Whilst the purple is a user’s day. Quite sensibly the user’s day starts at 00.00 and ends just before 00.00 the following day.


The two windows match perfectly and sometime during the following day we receive data for all 24 hours for the previous day.

However, during summer time this is how the windows look. The user’s day still starts at ends at 00.00 but that 00.00 doesn’t align with the electricity industry’s 00.00.


The user’s day starts an hour earlier than the electricity industry’s.

That means that when data is sent from the distribution company to Energimolnet the next day we receive an hour of the current day as well (we always receive the yellow window). It’s not just an issue because we would have a strange graph with one hour of the current day, the more significant problem is that if we were to sum up the consumption for the day we must remember to sum up the consumption for the electricity industry day, and not the normal day, otherwise our apps would never match the bill one receives from the energy company.

So it’s key to remember that when you request a day from our API what you will receive is the electricity industry day, not the user’s day.

If you’re wondering what to display to the user we think it’s best to display:

  • All of the 24 hours you have received in an energimolnet request
  • The time in the USER’s timezone
  • During summer shift a displayed day by 1 hour so the user’s and the data’s windows are aligned

Displaying in the user’s timezone is slightly unintuitive, we’ve just said that we don’t get data in the user’s timezone. However, we wouldn’t want users to see their consumption peak according to us at 18.00 if they started cooking their dinner at 19.00. It wouldn’t make sense to them and it would defeat the purpose of the app.

It does mean that if their phone is in a different timezone (e.g., they’ve gone to the US) then the consumption will look strange but that hasn’t been too much of an issue yet. The best solution to that problem is to use the timezone of the location of the facility. For instance we could assume at the moment that all facilities are in Europe/Stockholm but supporting travelling users hasn’t been a priority to date.

The switch between summer and normal time

As this weekend we experienced the day where we switch from summer time to normal time I thought I would post pictures of how our apps handle that switch. You can see that on Saturday the displayed day starts with the hour 01.00-02.00 (as we explained above) and finishes with 00.00-01.00 of what the user’s Sunday.

In the displayed Sunday however we experience 02.00-03.00 twice which is why there is an extra hour between 01.00 and 06.00 on Sunday. The day finishes with the hour 23.00-24.00 which means that we’re back in alignment with the electricity industry day.

The Monday (Yesterday in the image) is normal time and matches perfectly with the electricity industry so the displayed day starts with the hour 00.00-01.00 and finishes with the hour 23.00-24.00

screenshot-1383056222279 screenshot-1383056232786 screenshot-1383056239596

To simplify things a little I made this little table:

|        |                      | displayed day starts | displayed day ends |
|        |                      | with hour            | with hour          | 
| Summer | GMT +2 (Summer time) | 01.00-02.00          | 00.00-01.00        |
| Fall   | GMT +2 / +1          | 01.00-02.00          | 23.00-00.00        |
| Winter | GMT +1 (normal time) | 00.00-01.00          | 23.00-00.00        |
| Spring | GMT + 1 / +2         | 00.00-01.00          | 00.00-01.00        |
| Summer | GMT +2               | 01.00-02.00          | 00.00-01.00        |

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s