Page updated

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.

Sleep calculator

CaseWorked by handCalculatorResult
Cycles suggested for an adult: fewest whole 90-minute cycles above the CDC's 7 h55Pass
Cycles suggested for ages 6 to 12: above the CDC's 9 h, so 6 cycles (9 h) is not enough77Pass
Alarm 6:30 AM, adult: 6:30 AM minus 5 x 90 min minus 15 min10:45 PM10:45 PMPass
Same alarm, one cycle fewer (4 x 90 min = 6 h, below the CDC range)12:15 AM12:15 AMPass
Bed 11:00 PM, adult: plus 15 min plus 5 x 90 min, next morning6:45 AM6:45 AMPass
Bed 12:30 AM, adult: same day8:15 AM8:15 AMPass
Alarm 6:30 AM, teen: 6 cycles, because the CDC teen range starts at 8 h9:15 PM9:15 PMPass
Alarm 6:30 AM, adult, 25 min to fall asleep (NIOSH's normal onset) instead of 1510:35 PM10:35 PMPass
10:45 PM on the 24-hour clock22:4522:45Pass

Night-shift sleep planner

CaseWorked by handCalculatorResult
Shift 10 PM to 6 AM, 30 min home: in bed6:30 AM6:30 AMPass
Same, 7 h of sleep after 15 min to fall asleep: alarm1:45 PM1:45 PMPass
Same: sleep before 2 PM7 h7 hPass
Same, 20 min nap: leave 9:30 PM, ready 45 min earlier, minus 20 + 15 min: lie down8:10 PM8:10 PMPass
Same: last caffeine, 6 h before the 6:30 AM bedtime12:30 AM12:30 AMPass
Same: brighter light for the first half of the shift, until2:00 AM2:00 AMPass
Shift 7 PM to 7 AM, 90 min nap: lie down (75 min after waking)4:00 PM4:00 PMPass
Same: sleep before 2 PM (asleep 7:45 AM)6 h 15 min6 h 15 minPass
Shift 2:05 AM to 6:00 AM (under the 4 h minimum)no planno planPass

Nap planner

CaseWorked by handCalculatorResult
Lie down 2:00 PM, 60 min to spare, 20 min nap: 15 min to fall asleep + 20 min2:35 PM2:35 PMPass
Same, but a 90 min nap: 45 min of room, so the nap shortens to the 30 min top of a short nap30 min30 minPass
Lie down 2:00 PM, 120 min to spare, 90 min nap: alarm3:45 PM3:45 PMPass
Lie down 11:30 PM, 60 min to spare, 30 min nap: alarm after midnight12:15 AM12:15 AMPass
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 PM4:25 PMPass
A nap from 4:30 PM ending 5:05 PM, against that 5:00 PM limitinside the no-nap windowinside the no-nap windowPass

Sleep need by age

CaseWorked by handCalculatorResult
Age 5: US / UK / Canada / Australia hours (Australia's 5-13 band wins over 3-5)10-13 / none / 9-11 / 9-1110-13 / none / 9-11 / 9-11Pass
Age 138-10 / none / 9-11 / 9-118-10 / none / 9-11 / 9-11Pass
Age 18 (the CDC gives no upper figure for adults)7+ / 7-9 / 7-9 / 7-97+ / 7-9 / 7-9 / 7-9Pass
Age 657-8 / 7-9 / 7-8 / 7-87-8 / 7-9 / 7-8 / 7-8Pass
Age 13, 8.5 h a night, Canadian range 9 to 11 h30 min below30 min belowPass
Age 13, US, 7:00 AM alarm: bedtime window from 10 h down to 8 h of sleep, plus 15 min8:45 PM to 10:45 PM8:45 PM to 10:45 PMPass

Caffeine cut-off calculator

CaseWorked by handCalculatorResult
Brewed coffee, USDA: 40 mg per 100 g x 237 g95 mg95 mgPass
One coffee at 8:00 AM, bed 11:00 PM, half-life 5 h: 95 x (1/2)^3, left at bedtime11.9 mg11.9 mgPass
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 bed4:25 PM4:25 PMPass
Same with the 6 h half-life: 6 x log2(95 / 33.2) h before bed1:54 PM1:54 PMPass
One coffee, 50 mg at bed, 5 h: half-life allows 4.6 h, so the 6 h mark sets the time5:00 PM (6 h mark)5:00 PM (6 h mark)Pass
A 30 mg drink against a 50 mg bedtime figureany timeany timePass
95 mg against a 3 mg figure, 6 h: 6 x log2(95 / 3) = 29.9 h, more than a dayno time todayno time todayPass
Bed 1:00 AM, 7 mg figure, 6 h: 22.6 h before bed, so the time is labelled2:25 AM the morning before bed2:25 AM the morning before bedPass
Bed 12:00 AM, one coffee, 50 mg figure, 5 h: the 6 h mark, that evening, no label6:00 PM6:00 PMPass
Bed 11:00 PM, 6 mg figure, 6 h: 6 x log2(95 / 6) = 23.9 h before bed, the evening before11:05 PM the evening before bed11:05 PM the evening before bedPass
Bed 11:59 AM and 12:00 PM, 10 mg figure, 6 h: 19.5 h before bed either side of noon4:30 PM the afternoon before bed / 4:31 PM the afternoon before bed4:30 PM the afternoon before bed / 4:31 PM the afternoon before bedPass

Sleep debt calculator

CaseWorked by handCalculatorResult
Need 8 h, 6 h a night for 5 nights (NIOSH's own example)10 h10 hPass
Need 7 h, nights of 6, 6.5, 7, 8, 5, 7 and 9 h: 1 + 0.5 + 23.5 h3.5 hPass
Same week: nights short of the need33Pass
Need 7 h, three 9 h nights: long nights never cancel short ones, and there are none0 h0 hPass

Jet lag planner

CaseWorked by handCalculatorResult
UTC-5 to UTC+1: 6 h eastadvance 6 hadvance 6 hPass
UTC-5 to UTC+9: 14 h east is 10 h west, the shorter waydelay 10 hdelay 10 hPass
6 h east, 2 days of shifting before the flight, usual bed 11:00 PM: pre-trip day 1, 1 h earlier10:00 PM10:00 PMPass
Same: night 1 at the destination, 11 PM + 6 h - 2 h already shifted - 1 h2:00 AM2:00 AMPass
Same: nights at the destination (4 h left at 1 h a day)44Pass
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 shift9:30 PM9:30 PMPass
10 h west at 1.5 h a day: nights77Pass

Social jet lag calculator

CaseWorked by handCalculatorResult
Workdays 11 PM to 7 AM, free days 1 AM to 10 AM: mid-sleep3:00 AM vs 5:30 AM3:00 AM vs 5:30 AMPass
Same: the gap2 h 30 min2 h 30 minPass
Same: band (over 120 min is the top band, a studio rule)over 2 h bandover 2 h bandPass
Same: body clock low point, 2 to 4 h before the free-day wake6:00 AM to 8:00 AM6:00 AM to 8:00 AMPass
11:30 PM to 7 AM vs 12:30 AM to 9 AM: 3:15 AM vs 4:45 AM1 h 30 min1 h 30 minPass
A gap of exactly 120 min1 h to 2 h band1 h to 2 h bandPass

Share links

CaseWorked by handCalculatorResult
Sleep calculator link ?m=bed&t=23:00&age=teenbed, 23:00, teenbed, 23:00, teenPass
A link with a time that does not exist, ?t=25:00refusedrefusedPass
A link with only someone else's tracking tag, ?utm_source=pinignoredignoredPass
A link with the retired nap mode, ?m=naprefusedrefusedPass

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.