# Function getAgeTitle

### <a name="func_1"></a>

#### <span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">·</span></span><span lang="AR-SA"><span style="mso-spacerun: yes;"> </span>هدف:</span>

این متد یک ابزار کمکی ساده و کاربردی برای تعیین گروه سنی (`adult`, `child`, `infant`) یک شخص بر اساس تاریخ تولد و یک تاریخ مبنا (معمولاً تاریخ پرواز یا شروع اقامت) است. منطق آن بر اساس محاسبه اختلاف تعداد روزها بین دو تاریخ کار می‌کند. ابتدا تاریخ تولد را با استفاده از `Functions::checkDatetime` به فرمت استاندارد تبدیل کرده و سپس اختلاف آن با تاریخ مبنا را بر حسب روز محاسبه می‌کند. در نهایت، بر اساس قوانین استاندارد صنعت هوانوردی و گردشگری، گروه سنی را مشخص می‌کند: کمتر یا مساوی ۷۳۰ روز (۲ سال) به عنوان `infant` (نوزاد)، بین ۷۳۰ و ۴۳۸۰ روز (۲ تا ۱۲ سال) به عنوان `child` (کودک)، و بیشتر از ۴۳۸۰ روز (۱۲ سال) به عنوان `adult` (بزرگسال) در نظر گرفته می‌شود.

<table border="1" class="align-center" id="bkmrk-%D9%88%DB%8C%DA%98%DA%AF%DB%8C%E2%80%8C%D9%87%D8%A7-%D8%AA%D9%88%D8%B6%DB%8C%D8%AD%D8%A7%D8%AA-%D9%87%D8%AF%D9%81" style="border-collapse: collapse; width: 80.9524%; height: 196.891px; background-color: rgb(236, 202, 250); border: 1px inset rgb(206, 212, 217);"><colgroup><col style="width: 50.0736%;"></col><col style="width: 50.0736%;"></col></colgroup><thead><tr style="height: 30.7969px;"><td style="height: 30.7969px; border-color: rgb(206, 212, 217); background-color: rgb(132, 63, 161);"><span style="color: rgb(255, 255, 255);">**<span lang="AR-SA" style="font-family: 'B Titr';">ویژگی‌ها</span>**</span></td><td style="height: 30.7969px; border-color: rgb(206, 212, 217); background-color: rgb(132, 63, 161);"><span style="color: rgb(255, 255, 255);">**<span lang="AR-SA" style="font-family: 'B Titr';">توضیحات</span>**</span></td></tr></thead><tbody><tr style="height: 29.7969px; background-color: rgb(206, 212, 217);"><td style="height: 29.7969px; border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">هدف کلی</span>**</span></td><td style="height: 29.7969px; border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span lang="AR-SA" style="color: rgb(0, 0, 0);">تعیین گروه سنی (نوزاد، کودک، بزرگسال) بر اساس تاریخ تولد.</span></td></tr><tr style="height: 29.7969px; background-color: rgb(206, 212, 217);"><td style="height: 29.7969px; border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255);"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">منطق اصلی</span>**</span></td><td style="height: 29.7969px; border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255);"><span lang="AR-SA" style="color: rgb(0, 0, 0);">محاسبه اختلاف روز بین تاریخ تولد و تاریخ مبنا.</span></td></tr><tr style="height: 29.7969px; background-color: rgb(206, 212, 217);"><td style="height: 29.7969px; border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">قوانین سنی</span>**</span></td><td style="height: 29.7969px; border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span style="color: rgb(0, 0, 0);">`infant` &lt;= 2 سال, `child` &gt; 2 و &lt;= 12 سال, `adult` &gt; 12 سال.</span></td></tr><tr style="height: 30.1094px; background-color: rgb(206, 212, 217);"><td style="height: 30.1094px; border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255);"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">استانداردسازی ورودی</span>**</span></td><td style="height: 30.1094px; border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255);"><span style="color: rgb(0, 0, 0);">استفاده از `Functions::checkDatetime` برای مدیریت فرمت‌های مختلف تاریخ.</span></td></tr><tr><td style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">کاربرد</span>**</span></td><td style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span style="color: rgb(0, 0, 0);">ابزار کمکی داخلی برای استفاده در سایر متدهای نیازمند به گروه سنی.</span></td></tr></tbody></table>

<div align="right" id="bkmrk-"></div>---

#### <span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span><span lang="AR-SA">ورودی</span><span lang="FA" style="font-family: 'Calibri',sans-serif; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-language: FA;">‌ها (پارامتر‌ها):</span>

<span dir="LTR"> </span>

<table border="1" class="align-center" id="bkmrk-%D8%AA%D9%88%D8%B6%DB%8C%D8%AD%D8%A7%D8%AA-%D9%86%D9%88%D8%B9-%D8%AF%D8%A7%D8%AF%D9%87-%D9%86%D8%A7%D9%85" style="border-collapse: collapse; width: 80.9524%; height: 125.234px; background-color: rgb(236, 202, 250); border: 1px inset rgb(206, 212, 217);"><colgroup><col style="width: 50.0736%;"></col><col style="width: 12.5184%;"></col><col style="width: 12.5184%;"></col><col style="width: 25.0368%;"></col></colgroup><thead><tr style="height: 30.7969px;"><td style="height: 30.7969px; border-color: rgb(206, 212, 217); background-color: rgb(132, 63, 161);"><span style="color: rgb(255, 255, 255);">**<span lang="AR-SA" style="font-family: 'B Titr';">توضیحات</span>**</span></td><td style="border-color: rgb(206, 212, 217); background-color: rgb(132, 63, 161); height: 30.7969px;"><span style="color: rgb(255, 255, 255);">**<span lang="AR-SA" style="font-family: 'B Titr';">موقعیت</span>**</span></td><td style="height: 30.7969px; border-color: rgb(206, 212, 217); background-color: rgb(132, 63, 161);"><span style="color: rgb(255, 255, 255);">**<span lang="AR-SA" style="font-family: 'B Titr';">نوع داده</span>**</span></td><td style="border-color: rgb(206, 212, 217); background-color: rgb(132, 63, 161); height: 30.7969px;"><span style="color: rgb(255, 255, 255);">**<span lang="AR-SA" style="font-family: 'B Titr';">نام پارمتر</span>**</span></td></tr></thead><tbody><tr style="height: 47.2188px;"><td style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250); height: 47.2188px;"><span style="color: rgb(0, 0, 0);">**تاریخ تولد شخص در فرمت‌های مختلف (مثلاً `1990-05-20`, `1369/02/30`).**</span></td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250); height: 47.2188px;">**<span style="color: black; mso-color-alt: windowtext;">`Parameter`</span>**</td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250); height: 47.2188px;">**<span style="color: black; mso-color-alt: windowtext;">`string`</span>**</td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250); height: 47.2188px;"><span style="color: rgb(0, 0, 0);">**`$birth`**</span></td></tr><tr style="height: 47.2188px;"><td style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255); height: 47.2188px;"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">تاریخ مبنا برای محاسبه سن (مثلاً تاریخ پرواز).</span>**</span></td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255); height: 47.2188px;">**<span style="color: black; mso-color-alt: windowtext;">`Parameter`</span>**</td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255); height: 47.2188px;">**<span style="color: black; mso-color-alt: windowtext;">`string`</span>**</td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255); height: 47.2188px;"><span lang="AR-SA" style="color: rgb(0, 0, 0);">**<span style="color: black; mso-color-alt: windowtext;">`$datetime`</span>**</span></td></tr></tbody></table>

<div align="right" id="bkmrk--2"></div>---

#### <span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span><span lang="AR-SA">خروجی</span><span dir="LTR"> (Return)</span><span lang="FA" style="font-family: 'Calibri',sans-serif; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-language: FA;">:</span>

<span dir="LTR"> </span>

<div align="right" id="bkmrk-%D8%AA%D9%88%D8%B6%DB%8C%D8%AD%D8%A7%D8%AA-%D9%86%D9%88%D8%B9-%D8%AF%D8%A7%D8%AF%D9%87-%D8%B1%D8%B4%D8%AA"></div><table border="1" class="align-center" id="bkmrk-%D8%AA%D9%88%D8%B6%DB%8C%D8%AD%D8%A7%D8%AA-%D9%86%D9%88%D8%B9-%D8%AF%D8%A7%D8%AF%D9%87-%D8%B1%D8%B4%D8%AA-1" style="border-collapse: collapse; width: 80.9524%; height: 127.734px; background-color: rgb(236, 202, 250); border: 1px inset rgb(206, 212, 217);"><colgroup><col style="width: 50.0736%;"></col><col style="width: 50.0736%;"></col></colgroup><thead><tr style="height: 30.7969px;"><td style="height: 30.7969px; border-color: rgb(206, 212, 217); background-color: rgb(132, 63, 161);"><span style="color: rgb(255, 255, 255);">**<span lang="AR-SA" style="font-family: 'B Titr';">توضیحات</span>**</span></td><td style="height: 30.7969px; border-color: rgb(206, 212, 217); background-color: rgb(132, 63, 161);"><span style="color: rgb(255, 255, 255);">**<span lang="AR-SA" style="font-family: 'B Titr';">نوع داده</span>**</span></td></tr></thead><tbody><tr style="height: 48.4688px; background-color: rgb(206, 212, 217);"><td style="height: 48.4688px; border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA"><span dir="RTL" lang="AR-SA" style="font-size: 11.0pt; line-height: 107%; font-family: 'B Nazanin'; mso-ascii-font-family: 'B Nazanin'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-font-family: 'B Nazanin'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">یکی از سه رشته زیر: `'infant'`, `'child'`, `'adult'`.</span></span>**</span></td><td style="height: 48.4688px; border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span lang="AR-SA" style="color: rgb(0, 0, 0);">**<span style="font-size: 11.0pt; line-height: 107%; font-family: 'B Nazanin'; mso-ascii-font-family: 'B Nazanin'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-font-family: 'B Nazanin'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">`string`</span>**</span></td></tr></tbody></table>

---

#### <span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">·</span></span><span lang="AR-SA"><span style="mso-spacerun: yes;"> </span>مثا</span>ل استفاده / سناریو:

**<span style="text-decoration: underline; background-color: rgb(251, 238, 184);">سناریو ۱</span>: تعیین گروه سنی یک کودک**

- **Call:** `getAgeTitle('2015-08-01', '2025-10-15 14:30:00')`
- **Action:**

1. اختلاف روز بین `2015-08-01` و `2025-10-15` محاسبه می‌شود که تقریباً ۳۷۲۷ روز است.
2. `3727` بین `730` و `4380` قرار دارد.

- **Return:** `'child'`

**<span style="text-decoration: underline; background-color: rgb(251, 238, 184);">سناریو ۲</span>: تعیین گروه سنی یک نوزاد**

- **Call:** `getAgeTitle('1402/11/10', '2025-10-15 14:30:00')` -&gt; (1402/11/10 معادل 2024-01-30)
- **Action:**

1. `checkDatetime` تاریخ شمسی را به میلادی تبدیل می‌کند.
2. اختلاف روز بین `2024-01-30` و `2025-10-15` محاسبه می‌شود که تقریباً ۶۲۴ روز است.
3. `624` کمتر از `730` است.

- **Return:** `'infant'`