Converting UTC to local time in the dashboard and courseware pages

593 views
Skip to first unread message

Omar Al-Ithawi

unread,
Mar 8, 2015, 10:00:51 AM3/8/15
to edx-...@googlegroups.com
Hi,


The LMS shows the date/time in UTC in many pages including the dashboard and the courseware pages.
It is easy (at least to me) to immediately convert it to my local time.

As a student I would like to see it in my local time.

I have the following approaches for now:
  • Always provide the time in ISO UTC format and make the conversions on the client-side: 
    var date = new Date('2012-11-29 17:00:34 UTC');
    date.toString();
  • Ask the users for their timezone, calculate the local time on the server and print it. 
    There are many imperfect methods to figure out the user's timezone including: 1) Country? 2) IP Address, or 3) The browser's default timezone.

What do you think?

Thanks,

Leslie Gerhat

unread,
Mar 9, 2015, 5:07:31 PM3/9/15
to edx-...@googlegroups.com
Hi Omar, 

That seems like a reasonable approach to me. We'd love to see this come back to the platform as a pull request if you take it on. One note on where to pull the time zone. For the most reliable information, I would wait until the under-development User API and Profile functionality releases to edX-platform (anticipated release end of March), where we'll give users the ability to specify their time zone in platform, as opposed to guessing it. All the methods you list can lead to inconsistent or incorrect, which is even worse than displaying it in UTC. 

Let me know if you have further questions or thoughts!

Thanks,

Leslie Gerhat
edX Product Manager
Teaching and Learning Tools

Chris Dodge

unread,
Mar 10, 2015, 12:41:49 PM3/10/15
to edx-...@googlegroups.com
Omar,

That sounds about right to me - doing the time conversion to local time on the client side via JavaScript, as the browser typically knows what timezone it is set in. This approach is what I am doing for a project here at edX: I send down to an Ajax client a ISO8601 formatted string and then convert to a display string in local time. I'm also using the DateJS utility library which I've found helpful in parsing ISO8601 formatting date strings.

However scope of work to have specifically the Open edX dashboard do the time conversion client-side is unknown to me. There might be a lot of code changes required. Then - unfortunately - other areas of the Open edX experience (e.g. inside courseware) is still presented in UTC, so changing the Dashboard is only a partial solution.

Best wishes and good luck,

Chris Dodge

Ovnicraft

unread,
Mar 10, 2015, 1:04:09 PM3/10/15
to edx-...@googlegroups.com
On Tue, Mar 10, 2015 at 11:41 AM, Chris Dodge <cdo...@edx.org> wrote:
Omar,

That sounds about right to me - doing the time conversion to local time on the client side via JavaScript, as the browser typically knows what timezone it is set in. This approach is what I am doing for a project here at edX: I send down to an Ajax client a ISO8601 formatted string and then convert to a display string in local time. I'm also using the DateJS utility library which I've found helpful in parsing ISO8601 formatting date strings.

However scope of work to have specifically the Open edX dashboard do the time conversion client-side is unknown to me. There might be a lot of code changes required. Then - unfortunately - other areas of the Open edX experience (e.g. inside courseware) is still presented in UTC, so changing the Dashboard is only a partial solution.

Hi all !,

I am trying to guess:

I was searching about and django introduce TZ support from 1.4[1] this helps, and there is many implementations around, here[2] one.

I really love how change date with:

{% load tz %}
    The UTC time is {{ object.date }}
{% localtime on %}
    The local time is {{ object.date }}
{% endlocaltime %}

This issue start with store TZ from user setting it on the fly and use tz tag.

Regards !

Best wishes and good luck,

Chris Dodge
@edx.org


On Monday, March 9, 2015 at 5:07:31 PM UTC-4, Leslie Gerhat wrote:
Hi Omar, 

That seems like a reasonable approach to me. We'd love to see this come back to the platform as a pull request if you take it on. One note on where to pull the time zone. For the most reliable information, I would wait until the under-development User API and Profile functionality releases to edX-platform (anticipated release end of March), where we'll give users the ability to specify their time zone in platform, as opposed to guessing it. All the methods you list can lead to inconsistent or incorrect, which is even worse than displaying it in UTC. 

Let me know if you have further questions or thoughts!

Thanks,

Leslie Gerhat
edX Product Manager
Teaching and Learning Tools

On Sunday, March 8, 2015 at 10:00:51 AM UTC-4, Omar Al-Ithawi wrote:
Hi,


The LMS shows the date/time in UTC in many pages including the dashboard and the courseware pages.
It is easy (at least to me) to immediately convert it to my local time.

As a student I would like to see it in my local time.

I have the following approaches for now:
  • Always provide the time in ISO UTC format and make the conversions on the client-side: 
    var date = new Date('2012-11-29 17:00:34 UTC');
    date.toString();
  • Ask the users for their timezone, calculate the local time on the server and print it. 
    There are many imperfect methods to figure out the user's timezone including: 1) Country? 2) IP Address, or 3) The browser's default timezone.

What do you think?

Thanks,

Omar Al-Ithawi

unread,
Mar 11, 2015, 9:19:46 AM3/11/15
to edx-...@googlegroups.com
Hi Leslie,

That sounds very reasonable to me, of course it's best to ask the user for their timezone explicitly instead of guessing it.
I'll see what can we work on after the user API release.

Thanks,
--
Omar Al-Ithawi

Senior Engineer, Edraak.org


Queen Rania Foundation

for Education & Development

T +962 6 4016464  Ext. 700

M +962 7 90574405

E oit...@qrf.org

Reply all
Reply to author
Forward
0 new messages