3

When creating a new Coursework via the Classroom API, a "due" date and time can be added ( Classroom API TimeOfDay reference ) and the instructions say that "The date and time zone are either not significant or are specified elsewhere.".

In the context of a class, my expectation was that the number sent would be the number displayed (the teacher generally knows what "11AM" will mean to the class).

However, what actually happens is that the time zone that the server communicating with the API is located in is used to interpret the time. I.e. if the teacher is two time zones away from the backend server, the time will be two hours out.

Is the documentation just wrong? Or is there some way to "specify elsewhere" which I can't find?

Dan
  • 1,249
  • 2
  • 16
  • 31
  • AFAIK, this is not yet available in the API. Try posting a [feature request](https://issuetracker.google.com/issues/new?component=191645&template=823908) for this, it can help class that has support multiple timezones (students studying in different timezones). – Mr.Rebot Dec 10 '18 at 01:44
  • Will do. Do you know BTW what it is actually doing? More experimentation appears to reveal that it is doing a conversion between the server timezone (mine is UTC) and ... something else. The timezone used when the class was created? – Dan Dec 11 '18 at 14:30

1 Answers1

0

This question is a little old, but I just went through some of the same issues, so responding here in case anyone else needs help...

It's not entirely clear how you formatted your create request based on the original question. The TimeOfDay object is used to set dueTime, and as stated in the docs, all dates and times for CourseWork create requests should be converted into UTC: https://developers.google.com/classroom/reference/rest/v1/courses.courseWork

I.e. you need to do any conversions into UTC based on your application/user needs, and the Google Classroom UI automatically converts this date/time into the user's local/date time. Currently there is no other way to do this with this API

Implementing this properly can get tricky depending on how your app/UI is set up, and is further complicated by variations like Daylight Savings Time. For example, if you are using JavaScript, JS dates use UTC internally, the user's browser tracks the current time for that user, and there is currently no other built in functionality for any other timezones. See some of the really excellent explanations about this (and various workarounds) below:

I hope that's at least a little helpful. It's hard to specifically answer your question about 'what's happening' without more information :)

frederj
  • 1,483
  • 9
  • 20