Subversion Repositories DevTools

Rev

Rev 5506 | Rev 5670 | 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 )
98
	' Ensures Nice Date format DD-Mon-YYYY HH:MM:SS
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
 
119 ghuddy 103
'-----------------------------------------------------------------------------------------------------------------------------
104
Function ToLongDate ( dDate )
105
	' DD/MM/YYYY  -> Saturday, June 26, 1943
106
	If IsNull(dDate) Then Exit Function
107
	ToLongDate = FormatDateTime(dDate, 1)
108
End Function
109
'-----------------------------------------------------------------------------------------------------------------------------
147 ghuddy 110
Function EuroDateTimeForCalendarControl(dDate)
111
   ' Ensures Euro DateTime format DD-MM-YYYY H24:MIN:SS
112
	If IsNull(dDate) Then Exit Function
113
   EuroDateTimeForCalendarControl = Day(dDate) &"-"& Month(dDate) &"-"& Year(dDate) &" "& Hour(dDate) & ":" & Minute(dDate) & ":" & Second(dDate)
114
End Function
115
'-----------------------------------------------------------------------------------------------------------------------------
119 ghuddy 116
Function TO_ORADATE ( SSdate )
117
	'DD/MM/YYYY -> ORADATE
118
	TO_ORADATE = "TO_DATE( '"& SSdate &"','DD/MM/YYYY' )"
119
End Function
120
'-----------------------------------------------------------------------------------------------------------------------------
121
Function ORA_SYSDATE ()
122
	ORA_SYSDATE = "TO_DATE( TO_CHAR( SYSDATE,'DD-MON-YYYY' ),'DD-MON-YYYY' )"
123
End Function
124
'-----------------------------------------------------------------------------------------------------------------------------
125
Function ORA_SYSDATETIME ()
126
	ORA_SYSDATETIME = "TO_DATE( TO_CHAR( SYSDATE,'DD-MON-YYYY HH24:MI:SS' ),'DD-MON-YYYY HH24:MI:SS' )"
127
End Function
128
'-----------------------------------------------------------------------------------------------------------------------------
129
Function Quotes( SSstr )
130
	If InStr(SSstr, "$") > 0 Then
131
		' PERL variable
132
		Quotes = """"& SSstr & """"
133
	Else
134
		' Not PERL variable
135
		Quotes = "'"& SSstr & "'"
136
	End If
137
End Function
138
'-----------------------------------------------------------------------------------------------------------------------------
159 ghuddy 139
Function DoubleQuotes( SSstr )
140
   DoubleQuotes = """"& SSstr & """"
141
End Function
142
'-----------------------------------------------------------------------------------------------------------------------------
119 ghuddy 143
Function To_JATS ( SSbt, SSpkg, SSver )
144
	If SSbt = "B" Then
145
		SSbt = "BuildPkgArchive"
146
	ElseIf SSbt = "L" Then
147
		SSbt = "LinkPkgArchive"
148
	End If
149
	To_JATS = SSbt &" ( "& Quotes( SSpkg ) &", "& Quotes( SSver ) &" );"
150
End Function
151
'-----------------------------------------------------------------------------------------------------------------------------
152
Function To_ANT ( SSpkg, SSver )
153
	To_ANT = "&lt;property name="""& SSpkg &""" value="""& SSver &"""/&gt;"
154
End Function
155
'-----------------------------------------------------------------------------------------------------------------------------
156
Function To_ClearCase ( SSpkgLabel )
157
	To_ClearCase = "element * "& SSpkgLabel
158
End Function
159
'-----------------------------------------------------------------------------------------------------------------------------
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
286
		NewLine_To_BR = Replace ( SSstr, VBNewLine, "<br>")
287
	End If
288
End Function
289
'-----------------------------------------------------------------------------------------------------------------------------
290
Function IsTicked ( ByVal nParId, ByVal sParList )
291
	' Used only with check boxes as they send comma-separated list
292
	nParId 	 = ","&  Replace(nParId, " ", "") &","
293
	sParList = ","&  Replace(sParList, " ", "") &","
147 ghuddy 294
 
119 ghuddy 295
	If InStr( sParList, nParId ) > 0 Then
296
		IsTicked = TRUE
297
	Else
298
		IsTicked = FALSE
299
	End If
300
End Function
301
'------------------------------------------------------------------------------------------------------------------
302
Function FormatVersion ( ByVal nVersion )
303
	Dim arrVersion, MajorVersion, MinorVersion
304
	If IsNull( nVersion ) Then Exit Function
147 ghuddy 305
	If NOT IsNumeric(nVersion) Then
119 ghuddy 306
		FormatVersion = nVersion
307
		Exit Function
308
	End If
147 ghuddy 309
 
119 ghuddy 310
	nVersion = FormatNumber( nVersion, 3 )
147 ghuddy 311
 
119 ghuddy 312
	arrVersion = Split( CStr( nVersion ), ".")
313
	MajorVersion = arrVersion(0)
314
	MinorVersion = CInt(arrVersion(1))
315
	FormatVersion = MajorVersion &"."& MinorVersion
147 ghuddy 316
 
119 ghuddy 317
End Function
318
'-----------------------------------------------------------------------------------------------------------------------------
147 ghuddy 319
%>