<%
    CONST L_DateFormat_Text = "4" '1 = mm/dd/yyyy, 2 = dd/mm/yyyy, 3 = yyyy/dd/mm, 4 = yyyy/mm/dd
    CONST L_TimeFormat_Text = "3" '1 = 24:60, 2 = 12:60 AM/PM, 3 = AM/PM 12:60
    CONST L_DateFirst_Text  = "1" '1 = Date Time, 2 = Time Date
    
    CONST L_TimeLabelAM_Text   = "ÉÏÎç"
    CONST L_TimeLabelPM_Text   = "ÏÂÎç"
    CONST L_DateSeparator_Text = "-" 'US time is MM/DD/YYYY, but GER is DD.MM.YYYY
    CONST L_TimeSeparator_Text = ":" 'US time is HH:MM:SS, but Faeroese is HH.MM.SS
    
    FUNCTION FormatDate(years, months, days)
        SELECT CASE L_DateFormat_Text
            CASE 1 'MM/DD/YYYY
                FormatDate = months & L_DateSeparator_Text & days & L_DateSeparator_Text & years
            CASE 2 'DD/MM/YYYY
                FormatDate = days & L_DateSeparator_Text & months & L_DateSeparator_Text & years
            CASE 3 'YYYY/DD/MM
                FormatDate = years & L_DateSeparator_Text & days & L_DateSeparator_Text & months
            CASE 4 'YYYY/MM/DD
                FormatDate = years & L_DateSeparator_Text & months & L_DateSeparator_Text & days
        END SELECT
    END FUNCTION
    
    ' Hours coming in must be based on a 24-hour clock
    FUNCTION FormatTime(hours, minutes, seconds)
        DIM timeLabel
        
        IF (10 > seconds) THEN
            seconds = "0" & seconds
        END IF
        IF (10 > minutes) THEN
            minutes = "0" & minutes
        END IF
    
        SELECT CASE L_TimeFormat_Text
            CASE 1 '24-hour clock
                FormatTime = hours & L_TimeSeparator_Text & minutes & L_TimeSeparator_Text & seconds
            CASE 2,3 '12-hour clock with AM/PM
                IF (12 < hours) THEN
                    hours     = hours - 12
                    timeLabel = L_TimeLabelPM_Text
                ELSE
                    IF (0 = hours) THEN
                        hours = 12 'midnight hour
                    END IF
                    
                    timeLabel = L_TimeLabelAM_Text
                END IF
                
                IF (2 = L_TimeFormat_Text) THEN
                    FormatTime = hours & L_TimeSeparator_Text & minutes & L_TimeSeparator_Text & seconds & " " & timeLabel
                ELSE
                    FormatTime = timeLabel & " " & hours & L_TimeSeparator_Text & minutes & L_TimeSeparator_Text & seconds
                END IF
        END SELECT
    END FUNCTION
    
    ' Hours coming in must be based on a 24-hour clock
    FUNCTION FormatDateTime(years, months, days, hours, minutes, seconds)
        SELECT CASE L_DateFirst_Text
            CASE 1 'Date before time
                FormatDateTime = FormatDate(years, months, days) & " " & FormatTime(hours, minutes, seconds)
            CASE 2 'Time before date
                FormatDateTime = FormatTime(hours, minutes, seconds) & " " & FormatDate(years, months, days)
        END SELECT
    END FUNCTION
%>
