When did the word gay become associated with homosexuality?

I heard this song recently. It's the Most Wonderful Time of the Year (1963).
It inspired this question.

It's the most wonderful time of the year
With the kids jingle belling
And everyone telling you be of good cheer
It's the most wonderful time of the year

It's the hap-happiest season of all
With those holiday greetings and gay happy meetings
When friends come to call
It's the hap-happiest season of all

The theme from The Flintstones TV show (1960-66) had a line that said "We'll have a gay old time".

Even then, gay was used to denote mirthfulness, not homosexuality.

So what happened?

When did the word gay become associated with homosexuality?
Post Opinion