Subversion Repositories DevTools

Rev

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