Subversion Repositories DevTools

Rev

Rev 6683 | Go to most recent revision | 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
'-----------------------------------------------------------------------------------------------------------------------------
180
Function Format4HTML ( SSstr )
181
	If IsNull(SSstr) Then Exit Function
182
	Dim tempSTR
183
	tempSTR = SSstr
184
	tempSTR = Replace( tempSTR, "&", "&amp;" )
185
	Format4HTML = tempSTR
186
End Function
187
'-----------------------------------------------------------------------------------------------------------------------------
188
Function Pipes2Commas ( SSstr )
189
	' replaces |1||2||3| to 1,2,3
190
	Pipes2Commas = Replace( SSstr, "||", "," )
191
	Pipes2Commas = Replace( Pipes2Commas, "|", "" )
192
End Function
193
'-----------------------------------------------------------------------------------------------------------------------------
194
Function QuoteCSV ( SSstr )
195
	Dim tempStr
196
	tempStr = SSstr
147 ghuddy 197
	If tempStr = "" Then
119 ghuddy 198
		QuoteCSV = ""
199
		Exit Function
200
	End If
147 ghuddy 201
 
119 ghuddy 202
	tempStr = Replace(tempStr, " ", "")		' remove any spaces
203
	QuoteCSV = "'"& Replace( UCase(tempStr), ",", "','") &"'"
204
End Function
205
'-----------------------------------------------------------------------------------------------------------------------------
206
Function QuoteCSVwithLIKE ( SSstr )
207
	Dim tempStr
208
	tempStr = SSstr
147 ghuddy 209
	If tempStr = "" Then
119 ghuddy 210
		QuoteCSVwithLIKE = ""
211
		Exit Function
212
	End If
147 ghuddy 213
 
119 ghuddy 214
	tempStr = Replace(tempStr, " ", "")		' remove any spaces
215
	QuoteCSVwithLIKE = "'%"& Replace( UCase(tempStr), ",", "','") &"'"
216
End Function
217
'-----------------------------------------------------------------------------------------------------------------------------
218
Function SplitPipes ( SSstr )
147 ghuddy 219
	' split |val1||val2||val3| to array
119 ghuddy 220
	SplitPipes = Split( Replace( Replace(SSstr,"||","%"), "|","") , "%" )
221
End Function
222
'-----------------------------------------------------------------------------------------------------------------------------
223
Function SplitAmpasans ( SSstr )
147 ghuddy 224
	' split &val1&&val2&&val3& to array
119 ghuddy 225
	SSstr = Left (SSstr, Len(SSstr)-1)	'remove last &
226
	SSstr = Right (SSstr, Len(SSstr)-1)	'remove first &
227
	SplitAmpasans = Split( SSstr , "&&" )
228
End Function
229
'-----------------------------------------------------------------------------------------------------------------------------
230
Function URLEncode ( SSstr )
231
	Dim tmpStr
232
	tmpStr = SSstr
233
	tmpStr = Replace(tmpStr, "'", "%27")	' Encode '
234
	tmpStr = Replace(tmpStr, """", "%22")	' Encode "
235
	tmpStr = Replace(tmpStr, ",", "%2C")	' Encode ,
236
	tmpStr = Replace(tmpStr, ";", "%3B")	' Encode ;
237
	tmpStr = Replace(tmpStr, VBNewLine, "%0D%0A")	' Encode new line
238
	URLEncode = tmpStr
239
End Function
240
'-----------------------------------------------------------------------------------------------------------------------------
241
Function URLDecode ( SSstr )
242
	Dim tmpStr
243
	tmpStr = SSstr
244
	tmpStr = Replace(tmpStr, "%27", "'")	' Decode '
245
	tmpStr = Replace(tmpStr, "%22", """")	' Decode "
246
	tmpStr = Replace(tmpStr, "%2C", ",")	' Decode ,
247
	tmpStr = Replace(tmpStr, "%3B", ";")	' Decode ;
248
	tmpStr = Replace(tmpStr, "%0D%0A", VBNewLine)	' Decode new line
249
	URLDecode = tmpStr
250
End Function
251
'-----------------------------------------------------------------------------------------------------------------------------
252
Function WURLEncode ( sText )
253
	If (NOT IsNull(sText)) AND ( sText <> "" ) Then
254
		WURLEncode = Server.URLEncode( sText )
255
	Else
256
		WURLEncode = sText
257
	End If
258
End Function
259
'-----------------------------------------------------------------------------------------------------------------------------
260
Function HTMLEncode ( sText )
261
	If (NOT IsNull(sText)) AND ( sText <> "" ) Then
262
		HTMLEncode = Server.HTMLEncode( sText)
263
	Else
264
		HTMLEncode = sText
265
	End If
266
End Function
267
'-----------------------------------------------------------------------------------------------------------------------------
268
Function Highlight_Substring ( SSstr, SSsubstr )
269
	Dim leftSTR, startPos
270
	startPos = InStr( 1, SSstr, SSsubstr, 1 )
147 ghuddy 271
 
119 ghuddy 272
	If startPos > 0 Then
273
		leftSTR = Left ( SSstr, startPos - 1 )
274
		Highlight_Substring = leftSTR &"<SPAN style='background:#ffff99;'>"& Mid( SSstr, startPos, Len(SSsubstr) ) &"</SPAN>"&  Right ( SSstr, Len(SSstr) - Len(leftSTR) - Len(SSsubstr)  )
275
	Else
276
		' Subtring not found
277
		Highlight_Substring = SSstr
278
	End If
147 ghuddy 279
 
119 ghuddy 280
End Function
281
'-----------------------------------------------------------------------------------------------------------------------------
282
Function NewLine_To_BR (SSstr)
147 ghuddy 283
	If SSstr = "" OR IsNull(SSstr) Then
119 ghuddy 284
		Exit Function
285
	Else
6627 dpurdie 286
        ' Remove trailing new lines and spaces
287
        While Asc(Right(SSstr, 1)) = 10 Or Asc(Right(SSstr, 1)) = 13
288
            SSstr = Left(SSstr, Len(SSstr) - 1)
6873 dpurdie 289
            If Len(SSstr) = 0 Then
290
                SSstr = " "
291
            End If
6627 dpurdie 292
        Wend
293
        SSstr = Trim(SSstr)
119 ghuddy 294
		NewLine_To_BR = Replace ( SSstr, VBNewLine, "<br>")
295
	End If
296
End Function
297
'-----------------------------------------------------------------------------------------------------------------------------
298
Function IsTicked ( ByVal nParId, ByVal sParList )
299
	' Used only with check boxes as they send comma-separated list
300
	nParId 	 = ","&  Replace(nParId, " ", "") &","
301
	sParList = ","&  Replace(sParList, " ", "") &","
147 ghuddy 302
 
119 ghuddy 303
	If InStr( sParList, nParId ) > 0 Then
304
		IsTicked = TRUE
305
	Else
306
		IsTicked = FALSE
307
	End If
308
End Function
309
'------------------------------------------------------------------------------------------------------------------
310
Function FormatVersion ( ByVal nVersion )
311
	Dim arrVersion, MajorVersion, MinorVersion
312
	If IsNull( nVersion ) Then Exit Function
147 ghuddy 313
	If NOT IsNumeric(nVersion) Then
119 ghuddy 314
		FormatVersion = nVersion
315
		Exit Function
316
	End If
147 ghuddy 317
 
119 ghuddy 318
	nVersion = FormatNumber( nVersion, 3 )
147 ghuddy 319
 
119 ghuddy 320
	arrVersion = Split( CStr( nVersion ), ".")
321
	MajorVersion = arrVersion(0)
322
	MinorVersion = CInt(arrVersion(1))
323
	FormatVersion = MajorVersion &"."& MinorVersion
147 ghuddy 324
 
119 ghuddy 325
End Function
326
'-----------------------------------------------------------------------------------------------------------------------------
147 ghuddy 327
%>