Search code examples
google-workspacegoogle-admin-sdkgoogle-admin-settings-api

gSuite Integeration Admin SDK Report API Date format


Hi Guys I am currently working on Gsuite Admin SDK Report API. I am successfully able to send the request and getting the response.
Now, the issue is that I am not able to identify the date format returned by
the Activities.list().
Here is a snippet:

"events": [
 {
  "type": "event_change",
  "name": "create_event",
  "parameters": [
  {
  "name": "event_id",
  "value": "jdlvhwrouwovhuwhovvwuvhw"
  },
  {
  "name": "organizer_calendar_id",
  "value": "[email protected]"
  },
  {
  "name": "calendar_id",
  "value": "[email protected]"
  },
  {
  "name": "target_calendar_id",
  "value": "[email protected]"
  },
  {
  "name": "event_title",
  "value": "test event 3"
  },
  {
  "name": "start_time",
  "intValue": "63689520600"
  },  
  { 
  "name": "end_time",
  "intValue": "63689524200"
  },
  {
  "name": "user_agent",
  "value": "Mozilla/5.0"
  }
 ]
}

]

Note: Please have a look at start_time and end_time and let me know if you guys have any idea about it. Please have a look and share some info and let me know if any other infomation is needed.


Solution

  • I ran into this same question when parsing google calendar logs. The time format they use are the number of seconds since January 1st, 0001 (0001-01-01).

    I never found documentation where they referenced that time format. Google uses this instead of epoch for some of their app logs.

    You can find an online calculator here https://www.epochconverter.com/seconds-days-since-y0 Use the one under "Seconds Since 0001-01-01 AD" and not the one under year zero.

    So your start_time of "63689520600" converts to March 30, 2019 5:30:00 AM GMT.

    If you want start_time to be in epoch, you could subtract 62135596800 seconds from the number. 62135596800 converts to January 1, 1970 12:00:00 AM when counting the number of seconds since 0001-01-01. Subtracting 62135596800 from the start_time would give you the number of seconds since January 1, 1970 12:00:00 AM AKA Epoch Time.

    Hope this helps.