Skip to content

Working day management in formula #1708

Answered by euu2021
MPE04 asked this question in Help
Feb 28, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Is RAF an attribute where the user sets the number of days to complete the task? If so, then:

import java.time.LocalDate
import java.time.DayOfWeek

// Function to add working days to the current date
def addWorkingDays(startDate, daysToAdd) {
    LocalDate result = startDate
    int addedDays = 0
    while (addedDays < daysToAdd) {
        result = result.plusDays(1)
        // Check if the current day is a weekday
        if (!(result.dayOfWeek == DayOfWeek.SATURDAY || result.dayOfWeek == DayOfWeek.SUNDAY)) {
            addedDays++
        }
    }
    return result
}

// Main script starts here
// Retrieve the 'RAF' attribute value as an integer
int rafDays = node['RAF'].num0.toInteger…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@MPE04
Comment options

@euu2021
Comment options

Answer selected by MPE04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants