Siman 344
Presented here for study, not as a practical ruling. The Shulchan Aruch rules by Sephardi custom, the Rema's glosses by Ashkenazi custom, and the Kitzur follows Ashkenazi custom. For a practical question, ask your rabbi.
א הַהוֹלֵךְ בַּמִּדְבָּר וְאֵינוֹ יוֹדֵעַ מָתַי הוּא שַׁבָּת, מוֹנֶה שִׁבְעָה יָמִים מִיּוֹם שֶׁנָּתַן אֶל לִבּוֹ שִׁכְחָתוֹ וּמְקַדֵּשׁ הַשְּׁבִיעִי בְּקִדּוּשׁ וְהַבְדָּלָה. וְאִם יֵשׁ לוֹ מִמַּה לְּהִתְפַּרְנֵס, אָסוּר לוֹ לַעֲשׂוֹת מְלָאכָה כְּלָל עַד שֶׁיִּכְלֶה מַה שֶּׁיֵּשׁ לוֹ וְאָז יַעֲשֶׂה מְלָאכָה בְּכָל יוֹם, אֲפִלּוּ בַּיּוֹם שֶׁמְּקַדֵּשׁ בּוֹ, כְּדֵי פַּרְנָסָתוֹ מְצֻמְצֶמֶת. וּמֻתָּר לֵילֵךְ בּוֹ בְּכָל יוֹם, אֲפִלּוּ בַּיּוֹם שֶׁמְּקַדֵּשׁ בּוֹ.
1 The Law of Someone Who Is Wandering in the Desert on Shabbat. Contains 2 Seifim: One who is wandering in the desert and does not when is Shabbat, counts seven days from the day he realized he did not know, and sanctifies the seventh day with Kiddush and Havdalah. If one has sustenance, one is forbidden from doing any work whatsoever until he uses what he has, and thereafter one should do work each day, even on the day he sanctifies, to achieve minimal sustenance. One is permitted to walk every day, even on the day he sanctifies.
ב הָיָה יוֹדֵעַ מִנְיַן יוֹם שֶׁיָּצָא בּוֹ, כְּגוֹן שֶׁיּוֹדֵעַ שֶׁהַיּוֹם יוֹם רְבִיעִי אוֹ יוֹם חֲמִישִׁי לִיצִיאָתוֹ אֲבָל אֵינוֹ יוֹדֵעַ בְּאֵיזֶה יוֹם יָצָא, מֻתָּר לַעֲשׂוֹת מְלָאכָה כָּל מַה שֶּׁיִּרְצֶה בְּיוֹם שְׁמִינִי לִיצִיאָתוֹ שֶׁבְּיוֹם כָּזֶה יָצָא מִבֵּיתוֹ, דִּבְוַדַּאי לֹא יָצָא בְּשַׁבָּת; וְכֵן בְּיוֹם ט"ו, וּבְיוֹם כ"ב, וְכֵן לְעוֹלָם.
2 If he knows how many days he has been walking, i.e. he knows that today is the fourth day or the fifth day since his departure, but he does not know on which day he left, he is permitted to do as much work as he wants on the eighth day since his departure, because on that day of the week he left his house, and he certainly did not leave on Shabbat, and so too on the fifteenth day and the twenty-second day, and so on.