Command Palette

Search for a command to run...

Hectal
Phase 7: Errors, Files and Data Formats
Python · Exercise 6 of 7 PreviousNext
Intermediate

Days between dates and a local time in UTC

Write days_between(a, b) that takes two ISO dates as text (such as "2026-03-01") and returns the whole number of days from a to b. It is negative when b is earlier.

Write to_utc(text, zone) that takes a local ISO date and time without an offset (such as "2026-07-01T09:00") and a time-zone name (such as "Europe/London") and returns the same moment in UTC as ISO text.

Then print days_between("2026-10-10", "2026-12-25").

What Check tests

  1. days_between counts days
  2. days_between is negative going backwards
  3. It handles a leap year
  4. The same day is 0 days apart
  5. A zone with a half-hour offset works
  6. London summer time is one hour ahead of UTC
  7. New York winter time is five hours behind UTC
  8. The program prints 76

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

main.py
Sign in to run your code.

Output

Press Run to see what your program prints.