Weeknumber / Weekday as number


I got a custom script wich returns the week number but it returns the wrong week number

This is the script i found on the forum and it returns 21 instead of 20 wich is todays week number

Can i do this without custom scrip and with variables instead? if not how do i get the current week number.

How do i also get the current day? Im using a script wich works and returns the current day but i want to transform lets say if its Monday to “1” and if its Friday it should converts to “5”

This is the script wich im using.
output = ‘week_number’

def WeekNumber() {
Calendar calendar = Calendar.getInstance();
def WeekofYear = calendar.get(Calendar.WEEK_OF_YEAR);
week_number = RNumber.of(WeekofYear)