にいたとき

when [someone] was in/at

→ に
phrase Rare #31,114
when [someone] was in/at Used after a place to refer to the time someone was there. The person is often understood from context.
JA: 日本にいたとき、毎日電車で通学しました。
EN: When I was in Japan, I commuted by train every day.

昨年ロンドンにいたとき、誰かが私の部屋に侵入して財布を盗んだ。

When I was in London last year, someone broke into my room and stole my wallet.

田舎にいたときと同じでいい

Just keep it the same as when I was living in the countryside.

— ライフ・イズ・ビューティフル (1997)

台湾にいたとき私は彼と友達になった。

I became friends with him when I was in Taiwan.

私は大学にいたとき政治の活動をしていた。

I was politically active when I was in college.

ジムは交換留学生として日本にいたとき、私たちの家に滞在した。

Jim stayed at our house while he was in Japan as an exchange student.

彼女は帆船にいたときとはまるで違う服装をしていた。

She was dressed completely differently from when she was on the sailboat.