#!/usr/bin/env python3
"""Convert nanosecond timestamp to Zurich local time."""

import sys
from datetime import datetime
from zoneinfo import ZoneInfo


def main():
    if len(sys.argv) != 2:
        print("Usage: python ts_timestamp.py <nanosecond_timestamp>")
        print("Example: python ts_timestamp.py 1769085258472696373")
        sys.exit(1)
    
    try:
        # Parse nanosecond timestamp
        ns_timestamp = int(sys.argv[1])
        
        # Convert to seconds (nanoseconds / 1e9)
        seconds = ns_timestamp / 1_000_000_000
        
        # Create datetime in UTC
        dt_utc = datetime.fromtimestamp(seconds, tz=ZoneInfo("UTC"))
        
        # Convert to Zurich timezone
        dt_zurich = dt_utc.astimezone(ZoneInfo("Europe/Zurich"))
        
        # Print formatted output
        print(f"Timestamp: {ns_timestamp}")
        print(f"UTC:       {dt_utc.strftime('%Y-%m-%d %H:%M:%S.%f %Z')}")
        print(f"Zurich:    {dt_zurich.strftime('%Y-%m-%d %H:%M:%S.%f %Z')}")
        
    except ValueError as e:
        print(f"Error: Invalid timestamp format - {e}")
        sys.exit(1)


if __name__ == "__main__":
    main()