Page updated October 16, 2026
How we test the calculators
A calculator that shows its sources should also show that it gets the arithmetic right. Here is every published case we check, the answer we worked out by hand and what the calculators give.
How the tests work
All eight calculators run on one engine: the same file runs in your browser, writes the worked examples on our pages and runs these tests. For each calculator we take real cases, work out the answer by hand from the values on the methodology and sources page, and check that the engine gives the same answer. The tables show the case, the answer worked by hand and what the calculator gives.
The tests run every time the site is rebuilt, and this page is generated from the test file itself, so it cannot show a result the tests do not. If any check fails, the build stops until the case or the calculator is fixed. 62 cases, all passing , on the data last checked October 16, 2026. Behind them, 782 further checks cover the edges: both sides of midnight and noon, the 24-hour clock, the edges of every age band, nap lengths that would end in deep sleep, caffeine cut-offs that would fall more than a day before bedtime or after it, and share links with values the calculators must refuse.
When a check or a reader turns up a mistake, the fix is logged in the changelog ; the October 5, 2026 entry , for example, records that the caffeine calculator used to print a clock time when no time that day would work.
Times are clock times, durations are hours and minutes, and caffeine is in milligrams. Where a case names a number of minutes or hours, it comes from the data file.
Case Worked by hand Calculator Result
Cycles suggested for an adult: fewest whole 90-minute cycles above the CDC's 7 h 5 5 Pass
Cycles suggested for ages 6 to 12: above the CDC's 9 h, so 6 cycles (9 h) is not enough 7 7 Pass
Alarm 6:30 AM, adult: 6:30 AM minus 5 x 90 min minus 15 min 10:45 PM 10:45 PM Pass
Same alarm, one cycle fewer (4 x 90 min = 6 h, below the CDC range) 12:15 AM 12:15 AM Pass
Bed 11:00 PM, adult: plus 15 min plus 5 x 90 min, next morning 6:45 AM 6:45 AM Pass
Bed 12:30 AM, adult: same day 8:15 AM 8:15 AM Pass
Alarm 6:30 AM, teen: 6 cycles, because the CDC teen range starts at 8 h 9:15 PM 9:15 PM Pass
Alarm 6:30 AM, adult, 25 min to fall asleep (NIOSH's normal onset) instead of 15 10:35 PM 10:35 PM Pass
10:45 PM on the 24-hour clock 22:45 22:45 Pass
Case Worked by hand Calculator Result
Shift 10 PM to 6 AM, 30 min home: in bed 6:30 AM 6:30 AM Pass
Same, 7 h of sleep after 15 min to fall asleep: alarm 1:45 PM 1:45 PM Pass
Same: sleep before 2 PM 7 h 7 h Pass
Same, 20 min nap: leave 9:30 PM, ready 45 min earlier, minus 20 + 15 min: lie down 8:10 PM 8:10 PM Pass
Same: last caffeine, 6 h before the 6:30 AM bedtime 12:30 AM 12:30 AM Pass
Same: brighter light for the first half of the shift, until 2:00 AM 2:00 AM Pass
Shift 7 PM to 7 AM, 90 min nap: lie down (75 min after waking) 4:00 PM 4:00 PM Pass
Same: sleep before 2 PM (asleep 7:45 AM) 6 h 15 min 6 h 15 min Pass
Shift 2:05 AM to 6:00 AM (under the 4 h minimum) no plan no plan Pass
Case Worked by hand Calculator Result
Lie down 2:00 PM, 60 min to spare, 20 min nap: 15 min to fall asleep + 20 min 2:35 PM 2:35 PM Pass
Same, but a 90 min nap: 45 min of room, so the nap shortens to the 30 min top of a short nap 30 min 30 min Pass
Lie down 2:00 PM, 120 min to spare, 90 min nap: alarm 3:45 PM 3:45 PM Pass
Lie down 11:30 PM, 60 min to spare, 30 min nap: alarm after midnight 12:15 AM 12:15 AM Pass
Bed 11:00 PM, no nap in the last 6 h before bed: latest start for a 20 min nap (15 + 20 min before 5:00 PM) 4:25 PM 4:25 PM Pass
A nap from 4:30 PM ending 5:05 PM, against that 5:00 PM limit inside the no-nap window inside the no-nap window Pass
Case Worked by hand Calculator Result
Age 5: US / UK / Canada / Australia hours (Australia's 5-13 band wins over 3-5) 10-13 / none / 9-11 / 9-11 10-13 / none / 9-11 / 9-11 Pass
Age 13 8-10 / none / 9-11 / 9-11 8-10 / none / 9-11 / 9-11 Pass
Age 18 (the CDC gives no upper figure for adults) 7+ / 7-9 / 7-9 / 7-9 7+ / 7-9 / 7-9 / 7-9 Pass
Age 65 7-8 / 7-9 / 7-8 / 7-8 7-8 / 7-9 / 7-8 / 7-8 Pass
Age 13, 8.5 h a night, Canadian range 9 to 11 h 30 min below 30 min below Pass
Age 13, US, 7:00 AM alarm: bedtime window from 10 h down to 8 h of sleep, plus 15 min 8:45 PM to 10:45 PM 8:45 PM to 10:45 PM Pass
Case Worked by hand Calculator Result
Brewed coffee, USDA: 40 mg per 100 g x 237 g 95 mg 95 mg Pass
One coffee at 8:00 AM, bed 11:00 PM, half-life 5 h: 95 x (1/2)^3, left at bedtime 11.9 mg 11.9 mg Pass
Coffees at 8:00 AM and 1:00 PM, 50 mg at bed, 5 h: latest 2nd cup, 5 x log2(95 / 38.1) h before bed 4:25 PM 4:25 PM Pass
Same with the 6 h half-life: 6 x log2(95 / 33.2) h before bed 1:54 PM 1:54 PM Pass
One coffee, 50 mg at bed, 5 h: half-life allows 4.6 h, so the 6 h mark sets the time 5:00 PM (6 h mark) 5:00 PM (6 h mark) Pass
A 30 mg drink against a 50 mg bedtime figure any time any time Pass
95 mg against a 3 mg figure, 6 h: 6 x log2(95 / 3) = 29.9 h, more than a day no time today no time today Pass
Bed 1:00 AM, 7 mg figure, 6 h: 22.6 h before bed, so the time is labelled 2:25 AM the morning before bed 2:25 AM the morning before bed Pass
Bed 12:00 AM, one coffee, 50 mg figure, 5 h: the 6 h mark, that evening, no label 6:00 PM 6:00 PM Pass
Bed 11:00 PM, 6 mg figure, 6 h: 6 x log2(95 / 6) = 23.9 h before bed, the evening before 11:05 PM the evening before bed 11:05 PM the evening before bed Pass
Bed 11:59 AM and 12:00 PM, 10 mg figure, 6 h: 19.5 h before bed either side of noon 4:30 PM the afternoon before bed / 4:31 PM the afternoon before bed 4:30 PM the afternoon before bed / 4:31 PM the afternoon before bed Pass
Case Worked by hand Calculator Result
Need 8 h, 6 h a night for 5 nights (NIOSH's own example) 10 h 10 h Pass
Need 7 h, nights of 6, 6.5, 7, 8, 5, 7 and 9 h: 1 + 0.5 + 2 3.5 h 3.5 h Pass
Same week: nights short of the need 3 3 Pass
Need 7 h, three 9 h nights: long nights never cancel short ones, and there are none 0 h 0 h Pass
Case Worked by hand Calculator Result
UTC-5 to UTC+1: 6 h east advance 6 h advance 6 h Pass
UTC-5 to UTC+9: 14 h east is 10 h west, the shorter way delay 10 h delay 10 h Pass
6 h east, 2 days of shifting before the flight, usual bed 11:00 PM: pre-trip day 1, 1 h earlier 10:00 PM 10:00 PM Pass
Same: night 1 at the destination, 11 PM + 6 h - 2 h already shifted - 1 h 2:00 AM 2:00 AM Pass
Same: nights at the destination (4 h left at 1 h a day) 4 4 Pass
UTC-5 to UTC-8 (3 h west), usual bed 11:00 PM, no pre-shift: night 1 bedtime on the destination clock, 11:00 PM less the 1.5 h still to shift 9:30 PM 9:30 PM Pass
10 h west at 1.5 h a day: nights 7 7 Pass
Case Worked by hand Calculator Result
Workdays 11 PM to 7 AM, free days 1 AM to 10 AM: mid-sleep 3:00 AM vs 5:30 AM 3:00 AM vs 5:30 AM Pass
Same: the gap 2 h 30 min 2 h 30 min Pass
Same: band (over 120 min is the top band, a studio rule) over 2 h band over 2 h band Pass
Same: body clock low point, 2 to 4 h before the free-day wake 6:00 AM to 8:00 AM 6:00 AM to 8:00 AM Pass
11:30 PM to 7 AM vs 12:30 AM to 9 AM: 3:15 AM vs 4:45 AM 1 h 30 min 1 h 30 min Pass
A gap of exactly 120 min 1 h to 2 h band 1 h to 2 h band Pass
Share links
Case Worked by hand Calculator Result
Sleep calculator link ?m=bed&t=23:00&age=teen bed, 23:00, teen bed, 23:00, teen Pass
A link with a time that does not exist, ?t=25:00 refused refused Pass
A link with only someone else's tracking tag, ?utm_source=pin ignored ignored Pass
A link with the retired nap mode, ?m=nap refused refused Pass
Found a result that looks wrong? Tell us with the inputs; we add it as a case, fix the calculator if needed and log the change in the changelog .