Carl
Level 15

Get your taxes done using TurboTax

Per the IRS rules, the primary custodian is the parent who had custody of the child for 183 or more nights during the tax year. In the case of a temporary absence, (such as spending the night at a friends house, or away for a week at camp, or attending college) those nights count as having lived with the parent of primary custody, provided the dependent left for the temporary absence from the same parent the child returned to at the end of the temporary absence.
I do note that the IRS definition of "temporary absence" is a rather grey area, based on what I can find on the IRS website. The best I find is at <a rel="nofollow" target="_blank" href="https://taxmap.irs.gov/taxmap/pub17/p17-017.htm#TXMP0f886b0f">https://taxmap.irs.gov/taxmap/pub17/p1...>, where I am substituting DCF for a detention facility.
If the parents separated or divorced during the tax year after Jun 30, then the primary custodian is the parent with whom the child lived with for more than half of the time during the tax year.