Whenever the plot suited it, hehe! Early TOS seemed resolute in that it was two centuries ahead ("Space Seed", "Squire of Gothos". Other episodes would implicate the 23rd century, as would "Star Trek II" - the same movie that forgot Chekov wasn't on board the ship at that time, fanon/headcanon/makeitup really doesn't count for much as we're not getting paid to script edit the show after it's released... so I'd vote for both if I could. The show's penchant was discussing the human condition and canonical details didn't matter until later. Especially when episodes like "The Enemy Within" had to consciously write around the lack of shuttlecraft despite having the ship have one until the second half of the first season and even by then the 200/300 year juggling act was still not resolved... Never mind Kirk and other characters were not fully fleshed out as Spock had emotions, Kirk was not always consistent in attitude, that and TV was made rather differently in the 1960s with no arcs, no planned out ideas, it's just a western set in space and they worked by the seat of their pants and came up with some rather awesome stuff along the way. Continuity came in afterward. Then came TNG, which didn't nimbly nor neatly toe the line either... then by VOY there was no such thing as continuity of any sort anymore, since too much continuity pegs one in and that's not going to keep viewers so they had to do something at the risk of breaking it, but thankfully the 1996 Borg movie already did that - even if VOY's first three years' worth of Borg stories acted as if the Queen didn't exist - not until 1998 with season 5 of the show... and insinuated Q introduced the Borg, which isn't true because "The Neutral Zone" telling of scooped up elements that were confirmed in "Q Who" show the Borg were already there and there are loads more examples... ugh, pedantry, pedantry, the scripts written in your name...