When flying to and from the United States, from/until what time does it count as days of presence from an IRS tax residence standpoint?
For example, if my plane entered the US airspace at 20:00 on May 1, landed (= touched the ground) in the US at 23:55 on May 1, that I exited the plane at 00:10 on May 2, and that I cleared the US immigration at 02:00 on May 2, then left the United States on May 3 at noon: does that count as 2 or 3 days of presence from an IRS tax residence standpoint? Same question if I exited the plane at 23:59 on May 1. Etc. Basically at what moment does the day of presence starts?
I know that from the US customs standpoint one enters the United States the moment one exits the plane, but I don't know what the IRS thinks of it.
I understand from https://www.investopedia.com/terms/1/183-day-rule.asp (mirror) that there are some exceptions, e.g.:
Days that do not count as days of presence include:
- Days that you commute to work in the U.S. from a residence in Canada or Mexico, if you do so regularly
- Days you are in the U.S. for less than 24 hours while in transit between two other countries
- Days you are in the U.S. as a crew member of a foreign vessel
- Days you are unable to leave the U.S. because of a medical condition that develops while you are there