Timezone/integer offset


I’m currently using the following in Advanced Settings to import Jira Issue timestamps for Hour of Day Created:

name = “Hour of Day Created”
data_type = “integer”
dimension = true
javascript_code = ‘’’
var hours = new Date(Date.parse(issue.fields.created)).getHours();
issue.fields.customfield_hour_of_day_created = hours;’’’

This pulls timestamps according to UTC and I cannot get it to offset for the correct timezone, no matter how I try to modify it. My question is that if I cannot get the Hour of Day Created value to import into EazyBI from Jira accurately, is there a way to alter/offset the integer value displayed in reports when using the associated Calculated Member? Or do you know how to offset that value in the Javascript pasted above?

Thank you

Hi @athundley ,

You can try to retrieve the timezone offset with the JavaScript methode getTimezoneOffset() - Date.prototype.getTimezoneOffset() - JavaScript | MDN.

The JavaScript code could look similar to the one below:

var createDate = new Date(Date.parse(issue.fields.created));
var hours = createDate.getHours() - (createDate.getTimezoneOffset() / 60) ;
issue.fields.customfield_hour_of_day_created = hours;

Roberts // support@eazybi.com

eazyBI for the Jira Cloud app won’t let you use the getTimezoneOffset() function as expected as eazyBI on cloud is using UTC timezone anyway, then TimezoneOffset will always be 0.

When using eazyBI for Jira Cloud to pull the hour from created date timestamp using the default timezone, you could try this code:

name = "Hour of Day Created"
data_type = "integer"
dimension = true
javascript_code = '''
issue.fields.customfield_hodc = parseInt(issue.fields.created.match(/T(\d\d):/)[1]);

Or you can manually use the offset if you know the difference vs. UTC:

javascript_code = '''
var tz_offset=-11;//hours from UTC
var c1=new Date(Date.parse(issue.fields.created));
c1.setHours(c1.getHours() + tz_offset);
var hours = c1.getHours();
issue.fields.customfield_hour_of_day_created = hours

Martins / eazyBI