'====================================================================
'機能 : GMT日付をローカル日付に変換する。
'引数 :
' GMT日付
'返却値 : ローカル日付
'====================================================================
Function gfdtGMT2Local(ByVal GMTDate)
If SG_blnErrorResumeNext Then
On Error Resume Next
End If
Dim intTime
Dim intMinute
Dim dtTempDate
Dim dtOutDate
If Left(SG_strTimeZone, 3) <> "GMT" Then
gfdtGMT2Local = GMTDate
Exit Function
Else
Select Case Mid(SG_strTimeZone, 4, 1)
Case "+"
intTime = Mid(SG_strTimeZone, 5, 2)
intMinute = Mid(SG_strTimeZone, 8, 2)
If 0 <= intTime And intTime < 24 Then
If 0 <= intMinute And intMinute < 60 Then
dtTempDate = DateAdd("h", intTime, GMTDate)
dtOutDate = DateAdd("n", intMinute, dtTempDate)
Else
gfdtGMT2Local = GMTDate
Exit Function
End If
Else
gfdtGMT2Local = GMTDate
Exit Function
End If
Case "-"
intTime = Mid(SG_strTimeZone, 5, 2)
intMinute = Mid(SG_strTimeZone, 8, 2)
If 0 <= intTime And intTime < 24 Then
If 0 <= intMinute And intMinute < 60 Then
dtTempDate = DateAdd("h", -intTime, GMTDate)
dtOutDate = DateAdd("n", -intMinute, dtTempDate)
Else
gfdtGMT2Local = GMTDate
Exit Function
End If
Else
gfdtGMT2Local = GMTDate
Exit Function
End If
Case Else
gfdtGMT2Local = GMTDate
Exit Function
End Select
End If
gfdtGMT2Local = cdate(dtOutDate)
End Function
此博客展示了一个ASP函数gfdtGMT2Local,其功能是将GMT日期转换为本地日期。函数接收GMT日期作为参数,根据时区信息进行计算,通过判断时区的正负号及时间范围,使用DateAdd函数进行小时和分钟的加减,最终返回转换后的本地日期。
1万+

被折叠的 条评论
为什么被折叠?



