workTimer work flow using workdays and hours per day

I'd like to use some workflow to automatic add "Spent time" to tracks when using Time tracking. But workTimer default workflow doesn't support working days, hours per day etc.

I there any WF which does? Why are Workdays and Hour per day in settings, when I is not used at all? It's good enought to limit max. work time per day to set value (etc. 8 hours) and exclude weekends. Currently when I put task to state In process on Friday morning and set it as Fixed on Monday, it adds me e.g.60 hours - it's not useable at all.

Thx for any advice.
8 comments
Comment actions Permalink
Unfortunately, no.

As workaround you can define the day of week by the string Timer time.format(#e);

Also the following workflow should take into account work hours, please try:
var seconds = duration.millis / 1000;
var minutes = seconds / 60;
var hours = minutes / 60;
hours = hours - 16 * ((hours + 8) / 24);
var days = hours / 8;
 
minutes = minutes % 60;
hours = hours % 8;
 
if (days != 0) {
  message(l10n ( Work time:  {days}  day(s)  {hours}  hour(s)  {minutes}  minute(s). ));
} else if (hours != 0) {
  message(l10n ( Work time:  {hours}  hour(s)  {minutes}  minute(s). ));
} else {
  message(l10n ( Work time:  {minutes}  minute(s). ));
}
issue.applyCommand("add work Brief Client Review Today " + days + "d" + hours + "h" + minutes + "m" + " Brief Client Review Time Automagically Logged"); 
0
Comment actions Permalink
Hi, my be I'm missing something, but what is this line good for?
hours = hours - 16 * ((hours + 8) / 24);

Let's say I finished my work 10 hours after it has been started.
hours = 10 - 16 * ((10+8)/24)
hours = -2
That is wrong, isn't it?

I tried also count actual time, day of week etc. But I don't know, how to set date variable properly.
Let's say I need to count first day spent time as: Timer time.date at 18:00 - Timer time.time. How to set any variable this way?
I tried
var timerEvening = Timer time.format(#dd.MM.YYYY 18:00:00);

But timerEvening is becomes value in this case, not date time value. And I didn't find any way how to use some "semi constants"like this.
Any other idea?
0
Comment actions Permalink
Please try this updated formula: JT-22111.

Let's say I need to count first day spent time as: Timer time.date at 18:00 - Timer time.time. How to set any variable this way?

Unfortunately you cannot create a date field from scratch.
0
Comment actions Permalink
Finally I solved problem quite satisfactorily. I wrote this code, what work quite fine for our purposes.
All weekends and hollidays are not counted into final sum (there is list of Czech hollidays exclude Easter Monday).
rule Work finished 
 
when (State.oldValue == {Describing} && State.becomes({Describing}) == false) || (State.oldValue == {In Progress} && State.becomes({In Progress}) == false) || (State.oldValue == {Verification process} && State.becomes({Verification process}) == false) || (State.oldValue == {Documenting} && State.becomes({Documenting}) == false) { 
  var justNow = now; 
  var duration = justNow - Timer time; 
  var seconds = (duration.millis - duration.millis % 1000) / 1000; 
  var spentMinutes = (seconds - seconds % 60) / 60; 
  var workDays = 0; 
  var freeDays = 0; 
  var spentDays = 0; 
  var spentHours = (spentMinutes - spentMinutes % 60) / 60; 
  var workType = ""; 

  spentMinutes = spentMinutes % 60; 
   
  if (State.oldValue == {Describing}) { 
    workType = "Analyze"; 
  } 
  if (State.oldValue == {In Progress}) { 
    workType = "Development"; 
  } 
  if (State.oldValue == {Verification process}) { 
    workType = "Testing"; 
  } 
  if (State.oldValue == {Documenting}) { 
    workType = "Documentation"; 
  } 
   
  if (Timer time < justNow) { 
    while (justNow.format(#YYYY-MM-dd) != Timer time.format(#YYYY-MM-dd)) { 
      if ((justNow.format(#e) == "6") || (justNow.format(#e) == "7") || (justNow.format(#dd.MM.) == "01.01.") || (justNow.format(#dd.MM.) == "01.05.") || (justNow.format(#dd.MM.) == "08.05.") || (justNow.format(#dd.MM.) == "05.07.") || (justNow.format(#dd.MM.) == "06.07.") || (justNow.format(#dd.MM.) == "28.09.") || (justNow.format(#dd.MM.) == "28.10.") || (justNow.format(#dd.MM.) == "17.11.") || (justNow.format(#dd.MM.) == "24.12.") || (justNow.format(#dd.MM.) == "25.12.") || (justNow.format(#dd.MM.) == "26.12.")) { 
        freeDays = freeDays + 1; 
      } else { 
        workDays = workDays + 1; 
      } 
      justNow = justNow - 1 day; 
      if (workDays >= 250) { 
        issue.addComment("There is more than 250 working days, something is wrong!"); 
        break; 
      } 
    } 
  } 
  spentHours = spentHours - 24 * freeDays; 
  if (workDays > 0) { 
    workDays = workDays - 1; 
    spentHours = spentHours - 24 * workDays; 
    if (spentHours > 14) { 
      spentHours = spentHours - 14; 
    } else { 
      spentHours = 0; 
    } 
  } 
  if (workDays != 0) { 
    message(workType + " time " + workDays + " day(s) " + spentHours + " hour(s) " + spentMinutes + " minute(s)."); 
  } else if (spentHours != 0) { 
    message(workType + " time " + spentHours + " hour(s) " + spentMinutes + " minute(s)."); 
  } else { 
    message(workType + " time " + spentMinutes + "minute(s)."); 
  } 
  if (spentMinutes > 0 || spentHours > 0 || workDays > 0) { 
    issue.applyCommand("add work " + workType + " Today " + workDays + "d" + spentHours + "h" + spentMinutes + "m Work item added by RCS-workTimer"); 
  } 
}
0
Comment actions Permalink
Btw. that updated formula JT-22111 doesn't work any way ...
0
Comment actions Permalink
What's wrong on it? Please comment the issue itself.
0
Comment actions Permalink
I tried it on latest YT, but still all divisions are float, not integer. So got e.g. -5.333 hours when starting and stopping immediately, instead of 0 minutes as Andreas Larsens described.
0
Comment actions Permalink

Hi! I've started working on a solution for this problem, but am new to programming workflows. I'm wondering if you can point me to documentation about both Timer and also what language features are supported. To my front-end eye the code looks very Javascript-y and I'm wondering what's supported and not. Thanks!

0

Please sign in to leave a comment.