JavaScript Dates and Times for Pythonistas (Summary)

Larkspur Physio’s reminder script now runs in JavaScript. For the Thursday run, reminders.js prints the same eight lines as reminders.py, from the week’s header to Callum Reid: 1:20:00 booked, and Dana’s Sunday reminder stays at ten on Saturday morning while New York’s clocks go back.

Along the way, you’ve learned to:

  • Read Date code with zero-based month numbers, local getters and setters, and date-only strings interpreted as midnight UTC
  • Choose the Temporal type that says what you know
  • Read UTC timestamps with Temporal.Instant.from() and show them in each person’s zone with .toZonedDateTimeISO()
  • Order moments with Temporal.ZonedDateTime.compare() and compare dates with .equals()
  • Choose calendar days or elapsed hours on purpose across a clock change
  • Add up Duration values, balance them with .round(), and show them with Intl.DurationFormat
  • Format each patient’s time with .toLocaleString() and a locale you name

Keep and Drop Your Python Habits

Keep what Python’s datetime taught you: store moments as UTC timestamps alongside zone names, convert to a patient’s zone before local calendar arithmetic and display, and say which units you mean. The report’s run clock stays in UTC, as Python’s does. Six habits to drop:

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.