Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Documentation states that "TimeObject allows addition and subtraction of time quantities".

I can see that subtraction is fine, (example from doc page) TimeObject[{16, 17, 21}] - TimeObject[{10, 12, 34}] . This evaluates to time Quantity but if I change minus to plus the expression remains unevaluated.

However, both subtraction and addition works if TimeObject is used with time Quantity (e.g. 13 hours) instead of another TimeObject.

Subtraction is specifically mentioned in the following line from the docs: "Subtracting two TimeObject constructs yields a time quantity".

How about addition? Am I missing something or is it an obvious bug?

share|improve this question

closed as off-topic by m_goldberg, Öskå, bobthechemist, rasher, Mr.Wizard Jul 13 '14 at 23:40

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

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, Öskå, bobthechemist, rasher, Mr.Wizard
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

up vote 4 down vote accepted

Read what you quoted from the docs carefully. The phase "addition and subtraction of time quantities" does not mean "addition and subtraction of time objects". Subtraction works because it produces a time quantity, i.e., an interval. But what sense can be made of adding two time object? What would you expect to get from the sum of July 6, 1944 and July 4, 1776?


I should not have used dates in my question about the meaning of sums, although problem of addition is the same for times as for dates. The question should be: What would you expect to get from the sum of 8 AM and 2 PM?

share|improve this answer
Thanks for your reply. I see the point about quantities vs. TimeObjects. It makes sense but not completely. TimeObjects do not have dates, only times. I would expect to add TimeObject[{8,0,0}]+TimeObject[{8,0,0}] to see that Joe worked 16 hrs. Doesn't this addition make sense? What's the point of differentiation with DateObject then? –  user18488 Jul 13 '14 at 16:00
DateObject[] // FullForm gives DateObject[List[2014,7,13],TimeObject[List[12,19,4.867536`]]]. That should explain the difference. –  m_goldberg Jul 13 '14 at 16:22
Further, a TimeObject represents an event, a point in time. Joe can't work for TimeObject[{8,0,0}]. That doesn't represent 8 hours (a time quantity), but 8 AM. –  m_goldberg Jul 13 '14 at 16:26
Thank you @m_goldberg. Your last comments have cleared it up. Looks like the problem was my misunderstanding of what TimeObject actually represents. –  user18488 Jul 14 '14 at 4:45