Lesson 2: Time & Timestamps

In space missions, precise timing is critical. The ISS provides a timestamp with every coordinate reading. We need to be able to parse this time and use it for scheduling and analysis.

Session Goals
  • Understand Unix Timestamps.
  • Convert timestamps to readable Date/Time objects.
  • Extract specific time components (Hour, Minute, Second).
  • Calculate time intervals.

The Mission Task

We need to synchronize our instruments. Your task is to read the timestamp from the ISS, convert it into a human-readable format, and perform logic based on the specific time of the reading.

Key Concepts

Unix Timestamp
A way to track time as a running total of seconds. This count starts at the Unix Epoch on January 1st, 1970 at UTC.
Datetime Object
A Python object that represents a specific date and time, allowing us to easily extract year, month, day, hour, etc.
Modulo Operator (%)
Returns the remainder of a division. Useful for finding even/odd numbers or cycling through values.
Example: 5 % 2 is 1.

Orbit (ISS Tracker)

Provides real-time (simulated) coordinate data for the International Space Station.

from astro_pi_orbit import ISS
UsageDescription
iss = ISS()Initialize the ISS tracker.
iss.get_coordinates()Returns a dictionary with latitude, longitude, altitude, and timestamp.

Datetime

Standard Python library for handling dates and times.

from datetime import datetime, timedelta
UsageDescription
datetime.fromtimestamp(ts)Converts a Unix timestamp (seconds) into a readable date object.
datetime.now()Returns the current local date and time.
timedelta(seconds=x)Represents a duration of time (e.g., 5 seconds).

Mission Control Interface

Output Terminal
Ready to execute...