0 && $month >= 1 && $month <= 12 ); case '616': // YYYYWW if ( strlen( $value ) !== 6 || ! ctype_digit( $value ) ) { return false; } $year = (int) substr( $value, 0, 4 ); $week = (int) substr( $value, 4, 2 ); return ( $year > 0 && $week >= 1 && $week <= 53 ); } return false; } /** * Converts a CII date format code to a PHP date format. * * @param string $code CII date format code (e.g. 102, 610, 616). * @return string PHP-compatible date format string. */ public function get_php_date_format_from_code( string $code ): string { switch ( $code ) { case '102': // Full date: YYYYMMDD return 'Ymd'; case '610': // Year + Month: YYYYMM return 'Ym'; case '616': // Year + Week: YYYYWW (ISO) return 'oW'; default: return 'Ymd'; // Fallback } } }