Last active
March 1, 2021 06:30
-
-
Save vbcupu/78703a48b94862f1bf90b00188058bb0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Function ConvertToTglUnix(tgl As Date) As String | |
ConvertToTglUnix = (tgl - DateSerial(1970, 1, 1)) * 86400 | |
End Function | |
Private Function xtime(time As Date) As String | |
Dim the_date As Date | |
Dim system_time As SYSTEMTIME | |
Dim local_file_time As FILETIME | |
Dim utc_file_time As FILETIME | |
' Get the local time. | |
the_date = CDate(time) | |
' Convert it into a SYSTEMTIME. | |
DateToSystemTime the_date, system_time | |
' Convert it to a FILETIME. | |
SystemTimeToFileTime system_time, local_file_time | |
' Convert it to a UTC time. | |
LocalFileTimeToFileTime local_file_time, utc_file_time | |
' Convert it to a SYSTEMTIME. | |
FileTimeToSystemTime utc_file_time, system_time | |
' Convert it to a Date. | |
SystemTimeToDate system_time, the_date | |
' Display the result. | |
xtime = Format$(the_date) | |
End Function | |
' Convert a Date into a SYSTEMTIME. | |
Private Sub DateToSystemTime(ByVal the_date As Date, ByRef system_time As SYSTEMTIME) | |
With system_time | |
.wYear = Year(the_date) | |
.wMonth = Month(the_date) | |
.wDay = Day(the_date) | |
.wHour = Hour(the_date) | |
.wMinute = Minute(the_date) | |
.wSecond = Second(the_date) | |
End With | |
End Sub | |
'Convert a SYSTEMTIME into a Date. | |
Private Sub SystemTimeToDate(system_time As SYSTEMTIME, ByRef the_date As Date) | |
With system_time | |
'' The following doesn't work internationally. | |
'the_date = CDate( _ | |
' Format$(.wMonth) & "/" & _ | |
' Format$(.wDay) & "/" & _ | |
' Format$(.wYear) & " " & _ | |
' Format$(.wHour) & ":" & _ | |
' Format$(.wMinute, "00") & ":" & _ | |
' Format$(.wSecond, "00")) | |
' Thanks to Justin Starnes for the | |
' following internationalized version. | |
the_date = DateSerial(.wYear, .wMonth, .wDay) + _ | |
TimeSerial(.wHour, .wMinute, .wSecond) | |
End With | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment