#!/usr/bin/env python3
"""
Get Keith's current time correctly using system date command
"""

import subprocess
from datetime import datetime, timedelta

def get_keith_time_string():
    """Get current time string in Keith's timezone via system call"""
    try:
        result = subprocess.run(
            ['env', 'TZ=America/Denver', 'date', '+%A %B %d, %Y at %I:%M %p %Z'],
            capture_output=True, text=True
        )
        return result.stdout.strip() if result.returncode == 0 else None
    except Exception:
        return None

def get_keith_date():
    """Get Keith's current date as YYYY-MM-DD"""
    try:
        result = subprocess.run(
            ['env', 'TZ=America/Denver', 'date', '+%Y-%m-%d'],
            capture_output=True, text=True
        )
        return result.stdout.strip() if result.returncode == 0 else None
    except Exception:
        return None

def get_business_dates_from_keith_date():
    """Get next 5 business days from Keith's current date"""
    keith_date_str = get_keith_date()
    if not keith_date_str:
        return []
    
    # Parse Keith's date
    year, month, day = map(int, keith_date_str.split('-'))
    start_date = datetime(year, month, day).date()
    
    business_days = []
    current = start_date
    
    while len(business_days) < 5:
        if current.weekday() < 5:  # Monday=0, Friday=4
            business_days.append(current)
        current += timedelta(days=1)
    
    return business_days

if __name__ == "__main__":
    print(f"Keith's time: {get_keith_time_string()}")
    print(f"Keith's date: {get_keith_date()}")
    
    dates = get_business_dates_from_keith_date()
    print("Next 5 business days:")
    for date in dates:
        day_name = subprocess.run(
            ['env', 'TZ=America/Denver', 'date', '-d', str(date), '+%A'],
            capture_output=True, text=True
        ).stdout.strip()
        print(f"  - {day_name} {date}")
        
    print(f"\nConfirm Feb 16: {subprocess.run(['env', 'TZ=America/Denver', 'date', '-d', '2026-02-16', '+%A'], capture_output=True, text=True).stdout.strip()}")