How do I translate an ISO week string to a date value?

Jimmy Petersson August 20, 2021

Hi,

Working with project automation on Jira Server. My use-case is to translate an ISO week string '2053' (i e 2020 w53) to a date.

Field 'Progress Deviation Comment' contains string '2053'.

{{ issue.Progress Deviation Comment.toDate("yyww").jiraDate }}

However, my translation results in date '2020-12-27' (Sunday of w2052) instead of the expected date of '2020-12-28' (Monday of w2053). 

Testing indicates that toDate("yyww") use Sunday as first day of week and w2053 and w2101 results in same date:

  • String '2052' ->  '2020-12-20' (Sunday of ISO week 51) 
  • String '2053' ->  '2020-12-27' (Sunday of ISO week 52) 
  • String '2101' -> '2020-12-27' (Sunday of ISO week 52) 

Doing a check of week number using my locale of Sweden shows the expected week 33. 

{{now.locale("sv").weekOfYear}} 

I suspect adding locale is required for proper translation to ISO Week date, but I am unable to find any documentation on how to do this translation. Does anyone know?

 

Best Regards

//Jimmy

 

1 answer

0 votes
Bill Sheboy
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.
August 20, 2021

Hi @Jimmy Petersson 

Have you tried the convertToTimeZone() function to adjust the dates?
https://confluence.atlassian.com/automation/working-with-dates-993924630.html

And for more information about that locale function, the Atlassian documentation provides a link to here:
https://www.oracle.com/java/technologies/javase/jdk8-jre8-suported-locales.html

Best regards,
Bill

Jimmy Petersson August 24, 2021

Hi Bill and thanks for the suggestion.

I tried adding convertToTimeZone to my expression (needs locale("sv") in order not to fail rendering in project automation).

Convert IO_WEEK_NUM to date: {{issue.Progress Deviation Comment.toDate("yyww").locale("sv").convertToTimeZone("Sweden/Stockholm").jiraDate }}

But there is no value output:

Log
Convert IO_WEEK_NUM to date:

So I did not manage to convert to an ISO WEEK number using convertToTimeZone() function.

B R

//Jimmy

Bill Sheboy
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.
August 24, 2021

Sorry that didn't work for you, Jimmy.

At this point, I suggest having your site admin submit a ticket to support to see what they can find in the logs (...the ones we cannot see): https://support.atlassian.com/contact/#/

Then please post back here so the whole community can benefit.  Thanks!

Until you hear back from them, have you tried a work-around of adding a day with plusDays(1) or toBusinessDay() for the Monday?

François Dumas May 1, 2024

@Jimmy Petersson, I have exactly the same challenge.  Did you solve it in the end?

Suggest an answer

Log in or Sign up to answer