He repeated that phrase to set out his days of creation.
How could they be other than days from sun to sun?
So it took generations according to verse 4 but was counted as one day.
I don't think it does. The Hebrew word that you are reading translated as "generation" is a word that means an account, or a record or telling of the events and is translated that way in a number of Bible versions.
This is the account of the heavens and the earth when they were created, when the Lord God made the earth and the heavens. (Gen. 2:4 NIV)http://biblehub.com/genesis/2-4.htm
The word that is translated as "generations" in Genesis does not mean what you seem to think it means. It is not referring to an era of time. The word in question is "towlĕdah", which means:
I. descendants, results, proceedings, generations, genealogies
A. account of men and their descendants
i. genealogical list of one's descendants
ii. one's contemporaries
iii. course of history (of creation etc)
B. begetting or account of heaven (metaph)
http://www.blueletterbible.org/lang/Lexicon/Lexicon.cfm?strongs=H8435&t=KJV