(a) Sayyiduna Abu Hurayrah (may Allah be pleased with him) said that Abu al-Qasim (peace and blessings be upon him) said: "When one of you is in the sun (and Makhlad said: in the shade) and the shade recedes from him, so that part of him is in the sun and part in the shade, let him get up."
(b) In the narration of Abu al-Munib al-Ataki, Abdullah bin Buraydah reports from his father, from the Prophet (peace and blessings be upon him), a prohibition of that. This may mean that he intended it so that one is not harmed by the heat of the sun.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الجمعة / 5921