How to get list of timezone and their offsets from the Jira Cloud API?

I am using the url ‘https://micromine.atlassian.net/rest/api/3/myself’ to get the time zone of the logged in user so we can get the offset to the server. However it is in the format ‘Australia/Sydney’ with no corresponding offset.

I noticed there is a time zone API TimeZoneService (Atlassian JIRA 7.0.2 API), but I do not know how to connect to it. Can anyone point me in the right direction? I am using C# (.NET Framework) if that matters. Currently using REST API with json.

Hi @MBeeson
Welcome to our Community.

Please see getLocaleAndTimezone:
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-get

resolver.define("getXXX", async ({ context, payload }) => {
  const { accountId: userAccountId, siteUrl: siteURL } = context;

  const userAccount = await getLocaleAndTimezone(userAccountId);

  console.log(
    `>>>>>> User acount's locale & time zone are ${userAccount.locale} & ${userAccount.timeZone} respectively.`
  );
}

Thanks,
YY1

Thanks YY1. I did eventually come up with a alternate solution by matching the jira time zone name to a .net TimeZoneInfo object, then calculating the offset to the server (which is in UTC).

1 Like