If someone was in a desert or taken captive among the nations and lost track of when Shabbos is, he counts seven days and that day will be Shabbos for him, where he sanctifies it with kiddush and havdalah. This raises the question: This day may not be Shabbos?!
We know that the weekdays receive their nourishment from Shabbos as Sunday, Monday and Tuesday get nourished from the previous Shabbos whereas Wednesday, Thursday and Friday get it from the coming Shabbos. This is why at the end of the Shir Shel Yom of Wednesday, three days prior to Shabbos, we say Lechu Niraninah (the opening stanza of Kabbalas Shabbos), although it is not in that chapter of Tehillim (The Shir Shel Yom of Wednesday is from Tehillim chapter 94 whereas Lechu Niraninah is from chapter 95. The Shir Shel Yom of all the other days of the week is exclusively from one chapter of Tehillim.). It is included because from Wednesday on, the days are connected to the upcoming Shabbos.
Since the holiness of Shabbos is contained in each day so any day he makes Shabbos, due to him being in the desert or captured, it has some sanctity of Shabbos and as a result he can sanctify it with kiddush and havdalah, making it Shabbos for him.