Subversion Repositories DevTools

Rev

Rev 6873 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
119 ghuddy 1
<%
2
'=====================================================
3
'					 FORMATING
4
'=====================================================
5
%>
6
<%
7
'-----------------------------------------------------------------------------------------------------------------------------
5684 dpurdie 8
' Don't use - retained for legacy bits
119 ghuddy 9
Function EuroDate ( dDate )
10
	' Ensures Euro Date format DD/MM/YYYY
11
	If IsNull(dDate) Then Exit Function
12
	EuroDate = Day(dDate) &"/"& Month(dDate) &"/"& Year(dDate)
13
End Function
14
'-----------------------------------------------------------------------------------------------------------------------------
5632 dpurdie 15
Function DayName (intDay)
16
  '------------------------------------------
17
  ' Returns Abbreviated Day of Week
18
  '------------------------------------------
19
  select case intDay
20
      case 1
21
          DayName = "Sun"
22
      case 2
23
          DayName = "Mon"
24
      case 3
25
          DayName = "Tue"
26
      case 4
27
          DayName = "Wed"
28
      case 5
29
          DayName = "Thu"
30
      case 6
31
          DayName = "Fri"
32
      case 7
33
          DayName = "Sat"
34
  end select
35
end function
36
 
37
function MonthToName(intMonth)
38
  '-----------------------------------------
39
  ' Returns Abbreviated Month Name
40
  '-----------------------------------------
41
  select case intMonth
42
      case 1
43
         MonthToName = "Jan"
44
      case 2
45
         MonthToName = "Feb"
46
      case 3
47
         MonthToName = "Mar"
48
      case 4
49
         MonthToName = "Apr"
50
      case 5
51
         MonthToName = "May"
52
      case 6
53
         MonthToName = "Jun"
54
      case 7
55
         MonthToName = "Jul"
56
      case 8
57
         MonthToName = "Aug"
58
      case 9
59
         MonthToName = "Sep"
60
      case 10
61
         MonthToName = "Oct"
62
      case 11
63
         MonthToName = "Nov"
64
      case 12
65
          MonthToName = "Dec"
66
  end select
67
end function
68
 
69
Function DisplayShortDate ( dDate )
70
	' Ensures Nice Date format DD-Mon-YYYY
71
	If IsNull(dDate) Then Exit Function
72
	DisplayShortDate = Day(dDate) & "-" & MonthToName( Month(dDate)) & "-" & Year(dDate)
73
End Function
74
 
75
Function DisplayDate ( dDate )
76
	' Ensures Nice Date format Day DD-Mon-YYYY
77
	If IsNull(dDate) Then Exit Function
78
	DisplayDate = DayName (WeekDay(dDate)) & " " & Day(dDate) & "-" & MonthToName( Month(dDate)) & "-" & Year(dDate)
79
End Function
80
 
81
Function DisplayShortDateTime ( dDate )
82
	' Ensures Nice Date format DD-Mon-YYYY HH:MM
83
	If IsNull(dDate) Then Exit Function
84
	DisplayShortDateTime = DisplayShortDate ( dDate ) &" "& FormatDateTime( dDate, 4 )
85
End Function
86
 
87
Function DisplayDateTime ( dDate )
88
	' Ensures Nice Date format Day DD-Mon-YYYY HH:MM
89
	If IsNull(dDate) Then Exit Function
90
	DisplayDateTime = DisplayDate ( dDate ) &" "& FormatDateTime( dDate, 4 )
91
End Function
92
 
93
Function DisplayDateTimeSecs ( dDate )
5670 dpurdie 94
	' Ensures Nice Date format Day DD-Mon-YYYY HH:MM:SS
5632 dpurdie 95
	If IsNull(dDate) Then Exit Function
96
	DisplayDateTimeSecs = DisplayDate ( dDate ) &" "& Right("0" & Hour(dDate), 2) & ":" & Right("0" & Minute(dDate), 2) & ":" & Right("0" & Second(dDate), 2)
97
End Function
98
 
5670 dpurdie 99
Function DisplayShortDateTimeSecs ( dDate )
100
	' Ensures Nice Date format DD-Mon-YYYY HH:MM:SS
101
	If IsNull(dDate) Then Exit Function
102
	DisplayShortDateTimeSecs = DisplayShortDate ( dDate ) &" "& Right("0" & Hour(dDate), 2) & ":" & Right("0" & Minute(dDate), 2) & ":" & Right("0" & Second(dDate), 2)
103
End Function
104
 
119 ghuddy 105
'-----------------------------------------------------------------------------------------------------------------------------
106
Function ToLongDate ( dDate )
107
	' DD/MM/YYYY  -> Saturday, June 26, 1943
108
	If IsNull(dDate) Then Exit Function
109
	ToLongDate = FormatDateTime(dDate, 1)
110
End Function
111
'-----------------------------------------------------------------------------------------------------------------------------
112
Function TO_ORADATE ( SSdate )
113
	'DD/MM/YYYY -> ORADATE
114
	TO_ORADATE = "TO_DATE( '"& SSdate &"','DD/MM/YYYY' )"
115
End Function
116
'-----------------------------------------------------------------------------------------------------------------------------
117
Function ORA_SYSDATE ()
118
	ORA_SYSDATE = "TO_DATE( TO_CHAR( SYSDATE,'DD-MON-YYYY' ),'DD-MON-YYYY' )"
119
End Function
120
'-----------------------------------------------------------------------------------------------------------------------------
121
Function ORA_SYSDATETIME ()
122
	ORA_SYSDATETIME = "TO_DATE( TO_CHAR( SYSDATE,'DD-MON-YYYY HH24:MI:SS' ),'DD-MON-YYYY HH24:MI:SS' )"
123
End Function
124
'-----------------------------------------------------------------------------------------------------------------------------
125
Function Quotes( SSstr )
126
	If InStr(SSstr, "$") > 0 Then
127
		' PERL variable
128
		Quotes = """"& SSstr & """"
129
	Else
130
		' Not PERL variable
131
		Quotes = "'"& SSstr & "'"
132
	End If
133
End Function
134
'-----------------------------------------------------------------------------------------------------------------------------
159 ghuddy 135
Function DoubleQuotes( SSstr )
136
   DoubleQuotes = """"& SSstr & """"
137
End Function
138
'-----------------------------------------------------------------------------------------------------------------------------
119 ghuddy 139
Function To_JATS ( SSbt, SSpkg, SSver )
140
	If SSbt = "B" Then
141
		SSbt = "BuildPkgArchive"
142
	ElseIf SSbt = "L" Then
143
		SSbt = "LinkPkgArchive"
144
	End If
145
	To_JATS = SSbt &" ( "& Quotes( SSpkg ) &", "& Quotes( SSver ) &" );"
146
End Function
147
'-----------------------------------------------------------------------------------------------------------------------------
148
Function To_ANT ( SSpkg, SSver )
149
	To_ANT = "&lt;property name="""& SSpkg &""" value="""& SSver &"""/&gt;"
150
End Function
151
'-----------------------------------------------------------------------------------------------------------------------------
152
Function To_ClearCase ( SSpkgLabel )
153
	To_ClearCase = "element * "& SSpkgLabel
154
End Function
155
'-----------------------------------------------------------------------------------------------------------------------------
6683 dpurdie 156
Function To_Simple ( SSpkg, SSver )
157
	To_Simple = SSpkg & ", "& SSver
158
End Function
159
'-----------------------------------------------------------------------------------------------------------------------------
119 ghuddy 160
Function To_HTML ( sStr )
147 ghuddy 161
	If NOT IsNull(sStr) Then To_HTML = Server.HTMLEncode( sStr )
119 ghuddy 162
End Function
163
'-----------------------------------------------------------------------------------------------------------------------------
164
Function SQLstring ( SSstr )
165
	If IsNull(SSstr) OR (SSstr = "") Then Exit Function
166
	SQLstring = Replace( Trim(SSstr), "'", "''")
167
End Function
168
'-----------------------------------------------------------------------------------------------------------------------------
169
Function Format4Java ( SSstr )
170
	Dim tempSTR
171
	tempSTR = SSstr
172
	tempSTR = Replace( tempSTR, "'", "\'" )
173
	tempSTR = Replace( tempSTR, "&lt;", "\<" )
174
	tempSTR = Replace( tempSTR, "&gt;", "\>" )
175
	tempSTR = Replace( tempSTR, ";", "\;" )
176
	tempSTR = Replace( tempSTR, VBNEWLine, "\n" )
177
	Format4Java = tempSTR
178
End Function
179
'-----------------------------------------------------------------------------------------------------------------------------
6986 dpurdie 180
Function JSEncode ( SSstr )
181
	Dim tempSTR
182
	tempSTR = SSstr
183
    If SSstr <> "" Then
184
        tempSTR = Replace( tempSTR, "'", "&#39;" )
185
        tempSTR = Replace( tempSTR, """", "&#34;" )
186
    End If
187
	JSEncode = tempSTR
188
End Function
189
 
190
'-----------------------------------------------------------------------------------------------------------------------------
119 ghuddy 191
Function Format4HTML ( SSstr )
192
	If IsNull(SSstr) Then Exit Function
193
	Dim tempSTR
194
	tempSTR = SSstr
195
	tempSTR = Replace( tempSTR, "&", "&amp;" )
196
	Format4HTML = tempSTR
197
End Function
198
'-----------------------------------------------------------------------------------------------------------------------------
199
Function Pipes2Commas ( SSstr )
200
	' replaces |1||2||3| to 1,2,3
201
	Pipes2Commas = Replace( SSstr, "||", "," )
202
	Pipes2Commas = Replace( Pipes2Commas, "|", "" )
203
End Function
204
'-----------------------------------------------------------------------------------------------------------------------------
205
Function QuoteCSV ( SSstr )
206
	Dim tempStr
207
	tempStr = SSstr
147 ghuddy 208
	If tempStr = "" Then
119 ghuddy 209
		QuoteCSV = ""
210
		Exit Function
211
	End If
147 ghuddy 212
 
119 ghuddy 213
	tempStr = Replace(tempStr, " ", "")		' remove any spaces
214
	QuoteCSV = "'"& Replace( UCase(tempStr), ",", "','") &"'"
215
End Function
216
'-----------------------------------------------------------------------------------------------------------------------------
217
Function QuoteCSVwithLIKE ( SSstr )
218
	Dim tempStr
219
	tempStr = SSstr
147 ghuddy 220
	If tempStr = "" Then
119 ghuddy 221
		QuoteCSVwithLIKE = ""
222
		Exit Function
223
	End If
147 ghuddy 224
 
119 ghuddy 225
	tempStr = Replace(tempStr, " ", "")		' remove any spaces
226
	QuoteCSVwithLIKE = "'%"& Replace( UCase(tempStr), ",", "','") &"'"
227
End Function
228
'-----------------------------------------------------------------------------------------------------------------------------
229
Function SplitPipes ( SSstr )
147 ghuddy 230
	' split |val1||val2||val3| to array
119 ghuddy 231
	SplitPipes = Split( Replace( Replace(SSstr,"||","%"), "|","") , "%" )
232
End Function
233
'-----------------------------------------------------------------------------------------------------------------------------
234
Function SplitAmpasans ( SSstr )
147 ghuddy 235
	' split &val1&&val2&&val3& to array
119 ghuddy 236
	SSstr = Left (SSstr, Len(SSstr)-1)	'remove last &
237
	SSstr = Right (SSstr, Len(SSstr)-1)	'remove first &
238
	SplitAmpasans = Split( SSstr , "&&" )
239
End Function
240
'-----------------------------------------------------------------------------------------------------------------------------
241
Function URLEncode ( SSstr )
242
	Dim tmpStr
243
	tmpStr = SSstr
244
	tmpStr = Replace(tmpStr, "'", "%27")	' Encode '
245
	tmpStr = Replace(tmpStr, """", "%22")	' Encode "
246
	tmpStr = Replace(tmpStr, ",", "%2C")	' Encode ,
247
	tmpStr = Replace(tmpStr, ";", "%3B")	' Encode ;
248
	tmpStr = Replace(tmpStr, VBNewLine, "%0D%0A")	' Encode new line
249
	URLEncode = tmpStr
250
End Function
251
'-----------------------------------------------------------------------------------------------------------------------------
252
Function URLDecode ( SSstr )
253
	Dim tmpStr
254
	tmpStr = SSstr
255
	tmpStr = Replace(tmpStr, "%27", "'")	' Decode '
256
	tmpStr = Replace(tmpStr, "%22", """")	' Decode "
257
	tmpStr = Replace(tmpStr, "%2C", ",")	' Decode ,
258
	tmpStr = Replace(tmpStr, "%3B", ";")	' Decode ;
259
	tmpStr = Replace(tmpStr, "%0D%0A", VBNewLine)	' Decode new line
260
	URLDecode = tmpStr
261
End Function
262
'-----------------------------------------------------------------------------------------------------------------------------
263
Function WURLEncode ( sText )
264
	If (NOT IsNull(sText)) AND ( sText <> "" ) Then
265
		WURLEncode = Server.URLEncode( sText )
266
	Else
267
		WURLEncode = sText
268
	End If
269
End Function
270
'-----------------------------------------------------------------------------------------------------------------------------
271
Function HTMLEncode ( sText )
272
	If (NOT IsNull(sText)) AND ( sText <> "" ) Then
273
		HTMLEncode = Server.HTMLEncode( sText)
274
	Else
275
		HTMLEncode = sText
276
	End If
277
End Function
278
'-----------------------------------------------------------------------------------------------------------------------------
279
Function Highlight_Substring ( SSstr, SSsubstr )
280
	Dim leftSTR, startPos
281
	startPos = InStr( 1, SSstr, SSsubstr, 1 )
147 ghuddy 282
 
119 ghuddy 283
	If startPos > 0 Then
284
		leftSTR = Left ( SSstr, startPos - 1 )
285
		Highlight_Substring = leftSTR &"<SPAN style='background:#ffff99;'>"& Mid( SSstr, startPos, Len(SSsubstr) ) &"</SPAN>"&  Right ( SSstr, Len(SSstr) - Len(leftSTR) - Len(SSsubstr)  )
286
	Else
287
		' Subtring not found
288
		Highlight_Substring = SSstr
289
	End If
147 ghuddy 290
 
119 ghuddy 291
End Function
292
'-----------------------------------------------------------------------------------------------------------------------------
293
Function NewLine_To_BR (SSstr)
147 ghuddy 294
	If SSstr = "" OR IsNull(SSstr) Then
119 ghuddy 295
		Exit Function
296
	Else
6627 dpurdie 297
        ' Remove trailing new lines and spaces
298
        While Asc(Right(SSstr, 1)) = 10 Or Asc(Right(SSstr, 1)) = 13
299
            SSstr = Left(SSstr, Len(SSstr) - 1)
6873 dpurdie 300
            If Len(SSstr) = 0 Then
301
                SSstr = " "
302
            End If
6627 dpurdie 303
        Wend
304
        SSstr = Trim(SSstr)
119 ghuddy 305
		NewLine_To_BR = Replace ( SSstr, VBNewLine, "<br>")
306
	End If
307
End Function
308
'-----------------------------------------------------------------------------------------------------------------------------
309
Function IsTicked ( ByVal nParId, ByVal sParList )
310
	' Used only with check boxes as they send comma-separated list
311
	nParId 	 = ","&  Replace(nParId, " ", "") &","
312
	sParList = ","&  Replace(sParList, " ", "") &","
147 ghuddy 313
 
119 ghuddy 314
	If InStr( sParList, nParId ) > 0 Then
315
		IsTicked = TRUE
316
	Else
317
		IsTicked = FALSE
318
	End If
319
End Function
320
'------------------------------------------------------------------------------------------------------------------
321
Function FormatVersion ( ByVal nVersion )
322
	Dim arrVersion, MajorVersion, MinorVersion
323
	If IsNull( nVersion ) Then Exit Function
147 ghuddy 324
	If NOT IsNumeric(nVersion) Then
119 ghuddy 325
		FormatVersion = nVersion
326
		Exit Function
327
	End If
147 ghuddy 328
 
119 ghuddy 329
	nVersion = FormatNumber( nVersion, 3 )
147 ghuddy 330
 
119 ghuddy 331
	arrVersion = Split( CStr( nVersion ), ".")
332
	MajorVersion = arrVersion(0)
333
	MinorVersion = CInt(arrVersion(1))
334
	FormatVersion = MajorVersion &"."& MinorVersion
147 ghuddy 335
 
119 ghuddy 336
End Function
337
'-----------------------------------------------------------------------------------------------------------------------------
147 ghuddy 338
%>