@using System.Globalization
@inject HttpClient _hc
 <!-- header top area -->
<div class="header-top__area header-top__space z-index-3 d-none d-md-block tp-header-top-animation">
    <div class="container">
        <div class="row align-items-start">
            <div class="col-6">
                <div class="header-top__link">
                    <span>امروز <i>@GetTodyPersianDatetime()</i></span>

                </div>
            </div>
            <div class="col-6">
                <div class="header-top__support text-end">
                    <span>پیشتیبانی: <a href="tel:+989016940504">09016940504</a></span>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- header bottom -->

@code {
    DateTime dtserver = DateTime.Now;
    protected override async Task OnInitializedAsync()
    {
         dtserver = await _hc.GetFromJsonAsync<DateTime>("Base/DateTimeServer");
        await base.OnInitializedAsync();
    }
}
@functions{
    public string GetTodyPersianDatetime()
    {
        
        PersianCalendar pcDate = new PersianCalendar();
        int persianYear = pcDate.GetYear(dtserver);
        int persianMonth = pcDate.GetMonth(dtserver);
        int persianDay = pcDate.GetDayOfMonth(dtserver);

        string _DayOfWeek = "";
        switch (dtserver.DayOfWeek)
        {
            case DayOfWeek.Saturday:
                _DayOfWeek = " شنبه ";
                break;
            case DayOfWeek.Sunday:
                _DayOfWeek = " یکشنبه ";
                break;
            case DayOfWeek.Monday:
                _DayOfWeek = " دوشنبه ";
                break;
            case DayOfWeek.Tuesday:
                _DayOfWeek = " سه شنبه ";
                break;
            case DayOfWeek.Wednesday:
                _DayOfWeek = " چهارشنبه ";
                break;
            case DayOfWeek.Thursday:
                _DayOfWeek = " پنج شنبه ";
                break;
            case DayOfWeek.Friday:
                _DayOfWeek = " جمـــعه ";
                break;
        }
        string _Day = "";
        switch (persianDay)
        {
            case 1:
                _Day = " اول ";
                break;
            case 2:
                _Day = " دوم ";
                break;
            case 3:
                _Day = " سوم ";
                break;
            case 4:
                _Day = " چهارم ";
                break;
            case 5:
                _Day = " پنجم ";
                break;
            case 6:
                _Day = " ششم ";
                break;
            case 7:
                _Day = " هفتم ";
                break;
            case 8:
                _Day = " هشتم ";
                break;
            case 9:
                _Day = " نهم ";
                break;
            case 10:
                _Day = " دهم ";
                break;
            case 11:
                _Day = " یازدهم ";
                break;
            case 12:
                _Day = " دوازدهم ";
                break;
            case 13:
                _Day = " سیزدهم ";
                break;
            case 14:
                _Day = " چهاردهم ";
                break;
            case 15:
                _Day = " پانزدهم ";
                break;
            case 16:
                _Day = " شانزدهم ";
                break;
            default:
                _Day = persianDay.ToString();
                break;
        }
        string _Month = "";
        switch (persianMonth)
        {
            case 1:
                _Month = " فروردین ";
                break;
            case 2:
                _Month = " اردیبهشت ";
                break;
            case 3:
                _Month = " خرداد ";
                break;
            case 4:
                _Day = " تیر ";
                break;
            case 5:
                _Month = " مرداد ";
                break;
            case 6:
                _Month = " شهریور ";
                break;
            case 7:
                _Month = " مهر ";
                break;
            case 8:
                _Month = " آبان ";
                break;
            case 9:
                _Month = " آذر ";
                break;
            case 10:
                _Month = " دی ";
                break;
            case 11:
                _Month = " بهمن ";
                break;
            case 12:
                _Month = " اسفند ";
                break;

        }


        string fullPersianDate = _DayOfWeek + "  " + _Day + " " + _Month + " ماه " + persianYear;
        return fullPersianDate;
    }
}