Search code examples
pythondatetimegoogle-drive-apirfc3339

GoogleDrive date format?


I am trying to synchronise a file, but the drive is complaining about the date format. It says in the documentation that it uses RFC 3339 date formats, but this is the error I am getting when passing it a valid ISO RFC 3339 compliant date:

<HttpError 400 when requesting https://www.googleapis.com/drive/v2/files?alt=json returned "Invalid value for: Invalid format: "2013-06-13T20:19:24.000001" is too short">

The date is included, which I have artificially set a microsecond of 1, since I initially thought that Google Drive was being pedantic about the microsecond not being present. However, still get the same error whether the microsecond is present or not. I have also tried setting a UTC timezone, which appends +00:00. But then Google complains about the timezone offset being present.

Does anybody know what Google are expecting an RFC 3339 date format to look like?

Update: Thought I'd show the other format examples:

<HttpError 400 when requesting https://www.googleapis.com/drive/v2/files?alt=json returned "Invalid value for: Invalid format: "2013-06-13T20:19:24" is too short">

<HttpError 400 when requesting https://www.googleapis.com/drive/v2/files?alt=json returned "Invalid value for: Invalid format: "2013-06-13T20:19:24+00:00" is malformed at "+00:00"">

Solution

  • Use any RFC 3339 representation but avoid : as a separator for seconds. Instead, use ..

    2013-07-13T17:08:57.52Z and 2013-07-13T17:08:57.52-00:00 are working samples.