'====================================================================
'機能 : ローカル日付をGMT日付に変換する。
'引数 :
' ローカル日付
'返却値 : GMT日付
'====================================================================
Function gfdtLocal2GMT(ByVal LocalDate)
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
gfdtLocal2GMT = LocalDate
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, LocalDate)
dtOutDate = DateAdd("n", -intMinute, dtTempDate)
Else
gfdtLocal2GMT = LocalDate
Exit Function
End If
Else
gfdtLocal2GMT = LocalDate
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, LocalDate)
dtOutDate = DateAdd("n", intMinute, dtTempDate)
Else
gfdtLocal2GMT = LocalDate
Exit Function
End If
Else
gfdtLocal2GMT = LocalDate
Exit Function
End If
Case Else
gfdtLocal2GMT = LocalDate
Exit Function
End Select
End If
gfdtLocal2GMT = cdate(dtOutDate)
End Function
此博客展示了一个ASP函数gfdtLocal2GMT,其功能是将本地日期转换为GMT日期。函数会根据时区信息进行判断和计算,若时区格式不符合要求则直接返回本地日期,符合要求则根据时区的正负进行相应的时间加减操作。
1万+

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



