Imports System.Globalization
Imports System.Threading

Public Class ClsCalender

    Public grgCal As Calendar = New GregorianCalendar
    Public hijCal As Calendar = New HijriCalendar


    'التقويم الهجري والميلادي
#Region "Hijiri_Gregorian Calender"
    '==========================الحصول على التاريخ الهجري والميلادي========================
    '

    Public Function getGrgCal() As Date
        getGrgCal = grgCal.GetDayOfMonth(Now) & "/" & grgCal.GetMonth(Now) & "/" & grgCal.GetYear(Now)
    End Function

    Public Function getHijCal() As Date
        getHijCal = hijCal.GetDayOfMonth(Now) & "/" & hijCal.GetMonth(Now) & "/" & hijCal.GetYear(Now)
    End Function

    Public Function HijCalendar(ByVal Year As Integer, _
         ByVal Month As Integer, ByVal Day As Integer) As DateTime

        Try
            Dim Ar As CultureInfo = New CultureInfo("AR-SA")

            Thread.CurrentThread.CurrentCulture = Ar
            'Ar.DateTimeFormat.Calendar = New GregorianCalendar
            Ar.DateTimeFormat.Calendar = New HijriCalendar
            Ar.NumberFormat.DigitSubstitution = DigitShapes.NativeNational
            HijCalendar = New DateTime(Year, Month, Day, Ar.DateTimeFormat.Calendar)

        Catch ex As Exception
            ex = Nothing
        End Try

    End Function

    Public Function ArabicNumber() ' (ByVal rep As Object) As NumericFieldFormat

        Try
            Dim Ar As CultureInfo = New CultureInfo("AR-SA")

            Ar.NumberFormat.DigitSubstitution = New DigitShapes
            Ar.NumberFormat.DigitSubstitution = DigitShapes.NativeNational


        Catch ex As Exception
            MsgBox(ex.Message) '    ex = Nothing
        End Try


    End Function

    Public Function GrgCalendar(ByVal Year As Integer, _
     ByVal Month As Integer, ByVal Day As Integer) As DateTime

        Try
            Dim Ar As CultureInfo = New CultureInfo("AR-EG")

            Thread.CurrentThread.CurrentCulture = Ar
            'Ar.DateTimeFormat.Calendar = New HijriCalendar
            Ar.DateTimeFormat.Calendar = New GregorianCalendar
            GrgCalendar = New DateTime(Year, Month, Day, Ar.DateTimeFormat.Calendar)

        Catch ex As Exception
            ex = Nothing
            'MsgBox(ex.Message)
        End Try

    End Function

    'اظهار التاريخ الهجري والميلادي على النموذج
    'Public Sub AutoDateAndUser(ByRef lbl1 As String, ByRef lbl2 As String, ByRef lbl3 As String)
    '    Try
    '        lbl1 = Date.Now.ToString("  yyyy/MM/dd  م")
    '        lbl2 = "المستخدم :  " & User_Name
    '        lbl3 = getHijCal.ToString("  yyyy/MM/dd  هـ")
    '    Catch ex As Exception

    '    End Try

    ' End Sub

#End Region


End Class
