I am trying to convert the code below from VB6 to C#. I am just not sure where to begin, I guess maybe because I am sucked way to much into VB6 and can’t seem to take a step back.
Private Function GMT_OFFSET() As Integer
'****DECLARE VARIABLES
Dim dtNow As Date, dtEngland As Date
Dim dtGMT As SYSTEMTIME
'****GET SYSTEM TIME INFORMATION
Call GetSystemTime(dtGMT)
dtNow = Now
dtEngland = dtGMT.wYear & "-" & dtGMT.wMonth & "-" & dtGMT.wDay & " " & dtGMT.wHour & ":" & dtGMT.wMinute & ":" & dtGMT.wSecond
'****RETURN QUARTER HOURS
GMT_OFFSET = DateDiff("n", dtEngland, dtNow) \ 15
End Function
I know GetSystemTime is a Win32 API, obviously don’t want to do PInvoke in .NET but rather use the pure objects in the .NET Framework.
Near direct translation:
NB VB6’s
DateDiff(interval,date1,date2)results in intervals based upondate2 - date1, not vice versa.But the one-liner is: