#!/usr/bin/env python3
"""
wgctl format helper — date/time formatting utilities
"""
import sys

def fmt_datetime(iso_str, fmt):
    try:
        from datetime import datetime, timezone
        dt = datetime.fromisoformat(iso_str)
        if dt.tzinfo is None:
            dt = dt.replace(tzinfo=timezone.utc)
        print(dt.strftime(fmt))
    except:
        print(iso_str)

commands = {
    'fmt_datetime': lambda args: fmt_datetime(args[0], args[1]),
}

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print("Usage: fmt_helper.py <command> [args...]", file=sys.stderr)
        sys.exit(1)
    cmd = sys.argv[1]
    args = sys.argv[2:]
    if cmd not in commands:
        print(f"Unknown command: {cmd}", file=sys.stderr)
        sys.exit(1)
    commands[cmd](args)