Adding a time quantity to a TimeObject

In a calculation involving TimeObjects I noted that the addition of a time quantity to a TimeObject behaves differently depending on whether the TimeZone of the TimeObject is equal to the current $TimeZone or not.

For example the addition of 1 hour to a TimeObject with no explicit TimeZone

TimeObject[{12, 0, 0}] + Quantity[1, "Hours"]

yields the expected result (given in InputForm):

TimeObject[{13, 0, 0}, "Instant", None]

Similarly, when the TimeZone is set to the local TimeZone (in my case $TimeZone is 1.):

TimeObject[{12, 0, 0}, TimeZone -> $TimeZone] + Quantity[1, "Hours"]

yields (again in InputForm):

TimeObject[{13, 0, 0}, "Instant", 1.]

However, if a TimeObject in a TimeZone different from the local TimeZone (here: Tokyo) is used

TimeObject[{12, 0, 0},TimeZone -> LocalTimeZone[Entity["City", {"Tokyo", "Tokyo", "Japan"}]]]

which has the representation

TimeObject[{12, 0, 0}, "Instant", "Asia/Tokyo"]

adding one hour to it like

TimeObject[{12, 0, 0}, TimeZone -> LocalTimeZone[Entity["City", {"Tokyo", "Tokyo", "Japan"}]]] + Quantity[1, "Hours"]

does not yield, as I would have expected, 13 pm but instead (once more in InputForm):

TimeObject[{5, 0, 0}, "Instant", "Asia/Tokyo"]

What am I missing here?

Great find.

I’m in Chicago, and I get:

TimeObject[{23, 0, 0}, "Instant", "Asia/Tokyo"]

Looks like it might be a bug. Have you contacted technical support?

Hi Karsten,

as it seems one has to use the correct (i.e. the same) time zone to make this work the way you expect it:

$TimeZone = LocalTimeZone[Entity["City", {"Tokyo", "Tokyo", "Japan"}]];
TimeObject[{12, 0, 0}, TimeZone -> LocalTimeZone[Entity["City", {"Tokyo", "Tokyo", "Japan"}]]] + 
  Quantity[1, "Hours"] // InputForm
(*  Out:   TimeObject[{13, 0, 0}, "Instant", "Asia/Tokyo"]  *)

Henrik:

Thanks for figuring out a solution / work-around. But, this still does not make much sense to me. How does the duration of an hour depend on the timezone?

Mike,

yes, this is somewhat counterintuitive indeed!

Thanks for your feedback and suggestions. At least, I did not overlook something obvious. Going to contact the technical support about this.