2
$\begingroup$

I have a list of TimeObjects.

I want to subtract 5h from each element and if TimeObject < 5h then give a negative hour.

My goal is to count the amount of time that I’ve worked last month. To doing that I have a list of the amount time worked each day so that {{13/9,7:00}...} I make with that a list of DateValue to that I have to subtract 5h to each element to know only the extra time that i’ve worked.

How could I do this?

Edited.

$\endgroup$

closed as off-topic by Daniel Lichtblau, MarcoB, m_goldberg, user9660, Michael E2 Jan 30 '16 at 13:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – m_goldberg, Community
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Can't you just compute times - TimeObject[{5, 0, 0}]? That's what the documentation seems to imply. Count[..., _?Negative] or Count[..., _?Positive] etc. to count a particular type of result. $\endgroup$ – Michael E2 Jan 30 '16 at 13:15
  • $\begingroup$ I have corrected my answer according to the format you provided. Please accept it by selecting the tick mark if it answered your question. Thanks! $\endgroup$ – Pavlo Fesenko Feb 2 '16 at 13:02
2
$\begingroup$

If your working hours are stored in the list time according to the format you provided, then your total overtime can be calculated like this

time = {{"13/9", "7:00"}, {"14/9", "3:30"}};
overtime = TimeObject@DateList@{#[[2]], {"Hour", ":", "Minute"}} - 
 TimeObject@DateList@{"5:00", {"Hour", ":", "Minute"}} & /@ time;
Total@overtime
$\endgroup$
  • 1
    $\begingroup$ Why does ‘TimeObject’ subtraction shows in minutes? $\endgroup$ – kafkarudo Jan 30 '16 at 15:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.