Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Change date/hour format in queues

fran.quintero February 25, 2020

Hi all!

I have a date-hour picker, "Change start date", that I use as a custom field in a screen. As an agent I want to see in queues a column with the info of that "Change start date", but it shows me how much time is left (see attached file).

My question: Is there a way to see just the date-time that the reporter put on that custom field, and not the time remaining?

 

Thanks!change-start-date.jpg

1 answer

1 accepted

1 vote
Answer accepted
Nick Hassell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2020

I don't think you can do what you want (exactly).

If you have ScriptRunner, then read on...

I had the same issue, and created a custom text field.  I wrote a Script Listener that ran whenever the issue was changed, which populates the text field with a string representation of the 'Change Start Date'.  In my queues, I display the text field, but order by the date field.

If you are interested, here is my code (this board seems to have lost my spacing):

// Jira Service Desk queues show dates as relative (e.g. tomorrow) and do not show time
// This script creates a text string representing the absolute date and stores the string
// in a hidden text field for displaying in the queues

// Get the list of custom fields
def customFields = get("/rest/api/2/field")
.asObject(List)
.body
.findAll { (it as Map).custom } as List<Map>

// Get the values of interest from the current issue.
def startRelId = customFields.find { it.name == 'Change Start Date' }?.id
def startRel = "" as String
if (issue.fields[startRelId] != null){
startRel = issue.fields[startRelId]['value'] as String
} else {
logger.warn("Start date not set.")
return
}
def endRelId = customFields.find { it.name == 'Change End Date' }?.id
def endRel = "" as String
if (issue.fields[endRelId] != null){
endRel = issue.fields[endRelId]['value'] as String
} else {
logger.warn("End date not set.")
return
}

def startAbsId = customFields.find { it.name == 'Change Start' }?.id
def startAbs = "" as String
if (issue.fields[startAbsId] != null){
startAbs = issue.fields[startAbsId]['value'] as String
}
def endAbsId = customFields.find { it.name == 'Change End' }?.id
def endAbs = ""
if (issue.fields[endAbsId] != null){
endAbs = issue.fields[endAbsId]['value'] as String
}

def curStartAbs = getFormattedDateTime(startRel)
def curEndAbs = getFormattedDateTime(endRel)

if ((startAbs != curStartAbs) || (endAbs != curEndAbs)){
// At least one of the dates has changed (or is newly set)
setAbsDate (startAbsId, curStartAbs, endAbsId, curEndAbs)
logger.info ("Absolute dates updated.")
}

// ------------------------ END OF SCRIPT -----------------------------//

// This method creates a formatted date / time string
String getFormattedDateTime (String datetime){
Date startDate = Date.parse( "yyyy-MM-dd'T'HH:mm:ss.SSSZ", datetime )
def formattedDate = startDate.format("EEE dd MMM")
def formattedTime = startDate.format("HH:mm")
return formattedDate + ' ' + formattedTime
}

// This method sets the text fields with the supplied values
Void setAbsDate (String startAbsId, String startAbsDate, String endAbsId, String endAbsDate){
put("/rest/api/3/issue/${issue.key}")
.header("Content-Type", "application/json")
.body([
fields:[
(startAbsId) : startAbsDate,
(endAbsId) : endAbsDate
]
])
.asString()
return
}
Chris Shaffer May 15, 2020

Wow. That's more code than I'd need to write a date/time picker from scratch in TypeScript ... this is for what is supposed to be a working application.

Let's call this what it is: intentionally complicated functionality from Atlassian that should be a default setting.

The fact the date and time is displayed as the OP requested throughout the system but different in the queue is just like a big middle finger to tell us to buy more plugins.

The span tag above where the calculated time is at even has the actual value in it. They are going so far as to calculate the time from a UTC format an even display in in the UI but not allow you to configure it.

<span title="May 22, 2020 12:00 AM">
    <time class="allow-future" datetime="2020-05-22T00:00:00-0500" resolved="">
In 6 days
</time>
</span>

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events