<?php
namespace App\Utils;

class DateFormatter {
    public static function formatDaysFriendly(int $days): string {
        $days = abs($days);
        if ($days === 0) {
            return "0 days";
        }
        
        $years = floor($days / 365);
        $remainingDays = $days % 365;
        $months = floor($remainingDays / 30);
        $daysOut = $remainingDays % 30;
        
        $parts = [];
        if ($years > 0) {
            $parts[] = $years . ($years === 1.0 ? ' year' : ' years');
        }
        if ($months > 0) {
            $parts[] = $months . ($months === 1.0 ? ' month' : ' months');
        }
        if ($daysOut > 0) {
            $parts[] = $daysOut . ($daysOut === 1.0 ? ' day' : ' days');
        }
        
        return implode(', ', $parts);
    }
}
