MyTetra Share
Делитесь знаниями!
Дата - Перевод времени в GMT и обратно
Время создания: 16.03.2019 23:43
Раздел: !Закладки - VBA - Access - msa.polarcom.ru - 14 Преобразование Чисел и Дат
Запись: xintrea/mytetra_db_adgaver_new/master/base/1532018368add05gu5hh/text.html на raw.githubusercontent.com

Дата - Перевод времени в GMT и обратно

По материалам: http://www.excelfox.com/forum/f2/get-standard-gmt-time-from-the-system-using-vba-542/


Проверено, - работает (MSA-2010x32)

'--------------------------------------------------------------------

' Module : modGMT_Time

' Author : Rick Rothstein

' SRS : http://www.excelfox.com/forum/f2/get-standard-gmt-time-from-the-system-using-vba-542/

' Date : 01.02.2014

' Purpose : Перевод времени в GMT и обратно

'

'--------------------------------------------------------------------

'

Option Compare Database

Option Explicit


'

Private Type SYSTEMTIME

wYear As Integer

wMonth As Integer

wDayOfWeek As Integer

wDay As Integer

wHour As Integer

wMinute As Integer

wSecond As Integer

wMilliseconds As Integer

End Type


Private Type TIME_ZONE_INFORMATION

Bias As Long

StandardName(31) As Integer

StandardDate As SYSTEMTIME

StandardBias As Long

DaylightName(31) As Integer

DaylightDate As SYSTEMTIME

DaylightBias As Long

End Type


Private Declare Function GetTimeZoneInformation Lib "kernel32" _

(lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long


Public Function Local2GMT(dtLocalDate As Date) As Date

'Перевод местного времени в GMT

Local2GMT = DateAdd("s", -GetLocalToGMTDifference(), dtLocalDate)

End Function


Public Function GMT2Local(gmtTime As Date) As Date

'Перевод GMT в местное

GMT2Local = DateAdd("s", GetLocalToGMTDifference(), gmtTime)

End Function


Public Function GetLocalToGMTDifference() As Long

'Возвращает разницу во времени

Const TIME_ZONE_ID_INVALID& = &HFFFFFFFF

Const TIME_ZONE_ID_STANDARD& = 1

Const TIME_ZONE_ID_UNKNOWN& = 0

Const TIME_ZONE_ID_DAYLIGHT& = 2

Dim TimeZoneInf As TIME_ZONE_INFORMATION

Dim Ret As Long

Dim Diff As Long

Ret = GetTimeZoneInformation(TimeZoneInf)

Diff = -TimeZoneInf.Bias * 60

GetLocalToGMTDifference = Diff

If Ret = TIME_ZONE_ID_DAYLIGHT& Then

If TimeZoneInf.DaylightDate.wMonth <> 0 Then

GetLocalToGMTDifference = Diff - TimeZoneInf.DaylightBias * 60

End If

End If

End Function



Так же в этом разделе:
 
MyTetra Share v.0.59
Яндекс индекс цитирования