Search code examples
google-apigmail-api

VacationSettings.endTime in Gmail API is converting to the wrong date -- is it a bug or am I doing something wrong?


I am trying to update my Gmail vacation responder by using Gmail.users.settings.updateVacation. I am passing a VacationSettings like so:

{
    "restrictToContacts": false,
    "responseBodyHtml": "test",
    "responseSubject": "Out Of Office",
    "enableAutoReply": true,
    "restrictToDomain": false,
    "startTime": 1638933300000,
    "endTime": 1638936900000
}

startTime and endTime are epoch ms and translate to:

| key       | value         | date                     |
|-----------|---------------|--------------------------|
| startTime | 1638933300000 | 2021-12-07 @ 10:15:00 PM |
| endTime   | 1638936900000 | 2021-12-07 @ 11:15:00 PM |

But, in Gmail, it's setting the end date to 2021-12-06:

enter image description here

Am I doing something wrong or is this a bug/issue?


Solution

  • Contrary to Google's documentation, or what you see on the Gmail browser UI, you can schedule the vacation responder to turn on or off at the hour/minute/second. The Gmail browser UI may show the wrong date, but it will turn on and off as expected.

    So, for example, setting endTime to be a few minutes from now, will turn the vacation responder off at that time, even though the Gmail browser UI doesn't indicate that.