For purposes of this chapter, if a shareholder of an S corporation is both a resident and nonresident of this state during any taxable period, the shareholder’s pro rata share of the S corporation’s income attributable to the state and income not attributable to the state for the taxable period shall be further prorated between the shareholder’s periods of residence and nonresidence during the taxable period, in accordance with the number of days in each period.