Subversion Repositories DevTools

Rev

Rev 64 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%
'=====================================================
'                                        FORMATING
'=====================================================
%>
<%
'-----------------------------------------------------------------------------------------------------------------------------
Function EuroDate ( dDate )
        ' Ensures Euro Date format DD/MM/YYYY
        If IsNull(dDate) Then Exit Function
        EuroDate = Day(dDate) &"/"& Month(dDate) &"/"& Year(dDate)
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function EuroDateTime ( dDate )
        ' Ensures Euro DateTime format DD/MM/YYYY H24:MIN:SS
        If IsNull(dDate) Then Exit Function
        EuroDateTime = Day(dDate) &"/"& Month(dDate) &"/"& Year(dDate) &" "& FormatDateTime( dDate, 4 )
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function ToLongDate ( dDate )
        ' DD/MM/YYYY  -> Saturday, June 26, 1943
        If IsNull(dDate) Then Exit Function
        ToLongDate = FormatDateTime(dDate, 1)
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function TO_ORADATE ( SSdate )
        'DD/MM/YYYY -> ORADATE
        TO_ORADATE = "TO_DATE( '"& SSdate &"','DD/MM/YYYY' )"
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function ORA_SYSDATE ()
        ORA_SYSDATE = "TO_DATE( TO_CHAR( SYSDATE,'DD-MON-YYYY' ),'DD-MON-YYYY' )"
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function ORA_SYSDATETIME ()
        ORA_SYSDATETIME = "TO_DATE( TO_CHAR( SYSDATE,'DD-MON-YYYY HH24:MI:SS' ),'DD-MON-YYYY HH24:MI:SS' )"
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function Quotes( SSstr )
        If InStr(SSstr, "$") > 0 Then
                ' PERL variable
                Quotes = """"& SSstr & """"
        Else
                ' Not PERL variable
                Quotes = "'"& SSstr & "'"
        End If
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function To_JATS ( SSbt, SSpkg, SSver )
        If SSbt = "B" Then
                SSbt = "BuildPkgArchive"
        ElseIf SSbt = "L" Then
                SSbt = "LinkPkgArchive"
        End If
        To_JATS = SSbt &" ( "& Quotes( SSpkg ) &", "& Quotes( SSver ) &" );"
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function To_ANT ( SSpkg, SSver )
        To_ANT = "&lt;sandbox name="""& SSpkg &""" version="""& SSver &"""/&gt;"
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function To_ClearCase ( SSpkgLabel )
        To_ClearCase = "element * "& SSpkgLabel
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function To_HTML ( sStr )
        If NOT IsNull(sStr) Then To_HTML = Server.HTMLEncode( sStr ) 
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function SQLstring ( SSstr )
        If IsNull(SSstr) OR (SSstr = "") Then Exit Function
        SQLstring = Replace( Trim(SSstr), "'", "''")
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function Format4Java ( SSstr )
        Dim tempSTR
        tempSTR = SSstr
        tempSTR = Replace( tempSTR, "'", "\'" )
        tempSTR = Replace( tempSTR, "&lt;", "\<" )
        tempSTR = Replace( tempSTR, "&gt;", "\>" )
        tempSTR = Replace( tempSTR, ";", "\;" )
        tempSTR = Replace( tempSTR, VBNEWLine, "\n" )
        Format4Java = tempSTR
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function Format4HTML ( SSstr )
        If IsNull(SSstr) Then Exit Function
        Dim tempSTR
        tempSTR = SSstr
        tempSTR = Replace( tempSTR, "&", "&amp;" )
        Format4HTML = tempSTR
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function Pipes2Commas ( SSstr )
        ' replaces |1||2||3| to 1,2,3
        Pipes2Commas = Replace( SSstr, "||", "," )
        Pipes2Commas = Replace( Pipes2Commas, "|", "" )
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function QuoteCSV ( SSstr )
        Dim tempStr
        tempStr = SSstr
        If tempStr = "" Then 
                QuoteCSV = ""
                Exit Function
        End If
        
        tempStr = Replace(tempStr, " ", "")             ' remove any spaces
        QuoteCSV = "'"& Replace( UCase(tempStr), ",", "','") &"'"
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function QuoteCSVwithLIKE ( SSstr )
        Dim tempStr
        tempStr = SSstr
        If tempStr = "" Then 
                QuoteCSVwithLIKE = ""
                Exit Function
        End If
        
        tempStr = Replace(tempStr, " ", "")             ' remove any spaces
        QuoteCSVwithLIKE = "'%"& Replace( UCase(tempStr), ",", "','") &"'"
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function SplitPipes ( SSstr )
        ' split |val1||val2||val3| to array 
        SplitPipes = Split( Replace( Replace(SSstr,"||","%"), "|","") , "%" )
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function SplitAmpasans ( SSstr )
        ' split &val1&&val2&&val3& to array 
        SSstr = Left (SSstr, Len(SSstr)-1)      'remove last &
        SSstr = Right (SSstr, Len(SSstr)-1)     'remove first &
        SplitAmpasans = Split( SSstr , "&&" )
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function URLEncode ( SSstr )
        Dim tmpStr
        tmpStr = SSstr
        tmpStr = Replace(tmpStr, "'", "%27")    ' Encode '
        tmpStr = Replace(tmpStr, """", "%22")   ' Encode "
        tmpStr = Replace(tmpStr, ",", "%2C")    ' Encode ,
        tmpStr = Replace(tmpStr, ";", "%3B")    ' Encode ;
        tmpStr = Replace(tmpStr, VBNewLine, "%0D%0A")   ' Encode new line
        URLEncode = tmpStr
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function URLDecode ( SSstr )
        Dim tmpStr
        tmpStr = SSstr
        tmpStr = Replace(tmpStr, "%27", "'")    ' Decode '
        tmpStr = Replace(tmpStr, "%22", """")   ' Decode "
        tmpStr = Replace(tmpStr, "%2C", ",")    ' Decode ,
        tmpStr = Replace(tmpStr, "%3B", ";")    ' Decode ;
        tmpStr = Replace(tmpStr, "%0D%0A", VBNewLine)   ' Decode new line
        URLDecode = tmpStr
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function WURLEncode ( sText )
        If (NOT IsNull(sText)) AND ( sText <> "" ) Then
                WURLEncode = Server.URLEncode( sText )
        Else
                WURLEncode = sText
        End If
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function HTMLEncode ( sText )
        If (NOT IsNull(sText)) AND ( sText <> "" ) Then
                HTMLEncode = Server.HTMLEncode( sText)
        Else
                HTMLEncode = sText
        End If
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function Highlight_Substring ( SSstr, SSsubstr )
        Dim leftSTR, startPos
        startPos = InStr( 1, SSstr, SSsubstr, 1 )
        
        If startPos > 0 Then
                leftSTR = Left ( SSstr, startPos - 1 )
                Highlight_Substring = leftSTR &"<SPAN style='background:#ffff99;'>"& Mid( SSstr, startPos, Len(SSsubstr) ) &"</SPAN>"&  Right ( SSstr, Len(SSstr) - Len(leftSTR) - Len(SSsubstr)  )
        Else
                ' Subtring not found
                Highlight_Substring = SSstr
        End If
        
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function NewLine_To_BR (SSstr)
        If SSstr = "" OR IsNull(SSstr) Then 
                Exit Function
        Else
                NewLine_To_BR = Replace ( SSstr, VBNewLine, "<br>")
        End If
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function IsTicked ( ByVal nParId, ByVal sParList )
        ' Used only with check boxes as they send comma-separated list
        nParId   = ","&  Replace(nParId, " ", "") &","
        sParList = ","&  Replace(sParList, " ", "") &","
        
        If InStr( sParList, nParId ) > 0 Then
                IsTicked = TRUE
        Else
                IsTicked = FALSE
        End If
End Function
'------------------------------------------------------------------------------------------------------------------
Function FormatVersion ( ByVal nVersion )
        Dim arrVersion, MajorVersion, MinorVersion
        If IsNull( nVersion ) Then Exit Function
        If NOT IsNumeric(nVersion) Then 
                FormatVersion = nVersion
                Exit Function
        End If
        
        nVersion = FormatNumber( nVersion, 3 )
        
        arrVersion = Split( CStr( nVersion ), ".")
        MajorVersion = arrVersion(0)
        MinorVersion = CInt(arrVersion(1))
        FormatVersion = MajorVersion &"."& MinorVersion
        
End Function
'-----------------------------------------------------------------------------------------------------------------------------
Function GetBuildTypeString( enumBuildType )
        
        If (NOT IsNull(enumBuildType)) OR (NOT enumBuildType = "") Then
                
                Select Case CInt(enumBuildType)
                        Case enumDB_BUILD_TYPE_NONE
                                GetBuildTypeString = "Build type not applicable"
                                
                        Case enumDB_BUILD_TYPE_DEBUG
                                GetBuildTypeString = "Debug"
                                
                        Case enumDB_BUILD_TYPE_PROD
                                GetBuildTypeString = "Production"
                                
                        Case enumDB_BUILD_TYPE_PROD_AND_DEBUG
                                GetBuildTypeString = "Production and Debug"
                                
                        Case enumDB_BUILD_TYPE_JAVA_1_4
                                GetBuildTypeString = "Java 1.4"
                                
                        Case enumDB_BUILD_TYPE_JAVA_1_5
                                GetBuildTypeString = "Java 1.5"
                                
                End Select
                
        Else
                GetBuildTypeString = "Build type not defined"
        End If
        
        
End Function
'-----------------------------------------------------------------------------------------------------------------------------
%>