Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:18:12

Then We awakened them that We might show which of the two factions was most precise in calculating what ˹extent˺ they had remained in time.  

Then We aroused them, We awakened them, that We might know, a knowledge of direct vision, which of the two parties, the two groups in disagreement over the length of their stay ˹in the cave˺, was better in calculating (ahsā is ˹of the pattern˺ of af‘al, meaning ‘more precise’˺) what they had tarried (li-mā labithū is semantically connected to the following) in ˹terms of the˺ length of time (amadan, ˹in the accusative˺ denotes purpose).
القرآن:١٨:١٢

ثُمَّ بَعَثْنَاهُمْ لِنَعْلَمَ أَيُّ الْحِزْبَيْنِ أَحْصَىٰ لِمَا لَبِثُوا أَمَدًا  

{ثم بعثناهم} أيقظناهم {لنعلم} علم مشاهدة {أي الحزبين} الفريقين المختلفين في مدة لبثهم {أحصى} أفعل بمعنى أضبط {لما لبثوا} لبثهم متعلق بما بعده {أمدا} غاية.