GMT时间向Local时间转换(ASP)

'====================================================================
'機能 : 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

导航