All threads / Redmine Rails
Ask A Question

Notifications

You’re not receiving notifications from this thread.

Redmine Rails

Ondřej Láznička asked in Rails

Hi, i have trouble with ruby ( i dont know any ruby basics but im edititing redmine plugin ).

I prepared method
def getDateForRedmine( startDay, endDay, limit, date )

        datetime = Date.strptime(date.to_s,'%Y-%m-%d %H:%M:%s').to_datetime
        hour = datetime.hour.to_i
        minute = datetime.minute.to_i

        if hour >= startDay
            tempTime = hour + limit
            if tempTime < endDay
                return date.change(hour: tempTime).to_s(:db)
            elseif tempTime == endDay
                if minute > 0  then
                  return date.change(hour: startDay, day: 1).to_s(:db)
                else
                  return date.change(hour: tempTime).to_s(:db)
                end
            elseif tempTime > endDay
                if  hour > endDay
                    return getDateForRedmine(startDay,endDay, limit, date.change(hour: 8, day: 1) )
                else
                    remains = tempTime - endDay
                    return getDateForRedmine(startDay,endDay, remains, date.change(hour: 8, day: 1) )
                end
            end
        else

        end
    end

Which based on given values return datetime shifted.

Example of input
startDay = 8
endDay = 16
limit = 4
date = is current date

And it should return date shifted based on workday. But it keep returning nulll..

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 68,099+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.