Here is two function that calculate the GMT Offset of your station
'******************************************************************************************************************************************************
Sub GMTOffset()
Dim dResult as double;
Dim tmpResult as double;
Dim hdlDateTime as long;
Dim sDateTime as str;
Dim iYear as integer;
Dim iMonth as integer;
Dim iDay as integer;
Dim iHour as integer;
Dim iMinute as integer;
Dim iSecond as integer;
Dim iMilliSecond as integer;
Dim tmpDateTime as str;
Dim dGmtDelta as double;
Dim sGmtDelta as str;
sDateTime = DATETIMESTRING(DATETIMEVALUE(),"U");
'Get all parts of the DateTime
'Its format is "xxxx-xx-xxTxx:xx:xx.xxxZ"
hdlDateTime = ALLOC_BUFFER(30);
SEQ_BUFFER("PUT_LINE",hdlDateTime,sDateTime);
iYear = SEQ_BUFFER("NEXTFIELD",hdlDateTime,"-","INT");
iMonth = SEQ_BUFFER("NEXTFIELD",hdlDateTime,"-","INT");
iDay = SEQ_BUFFER("NEXTFIELD",hdlDateTime,"T","INT");
iHour = SEQ_BUFFER("NEXTFIELD",hdlDateTime,":","INT");
iMinute = SEQ_BUFFER("NEXTFIELD",hdlDateTime,":","INT");
iSecond = SEQ_BUFFER("NEXTFIELD",hdlDateTime,".","INT");
iMilliSecond = SEQ_BUFFER("NEXTFIELD",hdlDateTime,"Z","INT");
'Make a first convertion to double format
dResult = DATETIMEVALUE(iDay,iMonth,iYear,iHour,iMinute,iSecond,iMilliSecond);
'Convert back the result to string format
tmpDateTime = GMTDTDoubleToString(dResult);
'Split this result to get parts
SEQ_BUFFER("CLEAR",hdlDateTime);
SEQ_BUFFER("BEGIN",hdlDateTime);
SEQ_BUFFER("PUT_LINE",hdlDateTime,tmpDateTime);
iYear = SEQ_BUFFER("NEXTFIELD",hdlDateTime,"-","INT");
iMonth = SEQ_BUFFER("NEXTFIELD",hdlDateTime,"-","INT");
iDay = SEQ_BUFFER("NEXTFIELD",hdlDateTime,"T","INT");
iHour = SEQ_BUFFER("NEXTFIELD",hdlDateTime,":","INT");
iMinute = SEQ_BUFFER("NEXTFIELD",hdlDateTime,":","INT");
iSecond = SEQ_BUFFER("NEXTFIELD",hdlDateTime,".","INT");
iMilliSecond = SEQ_BUFFER("NEXTFIELD",hdlDateTime,"Z","INT");
'Make a convertion with theses values to double format
tmpResult = DATETIMEVALUE(iDay,iMonth,iYear,iHour,iMinute,iSecond,iMilliSecond);
'Difference between the 2 double result indicate the Time Shift with GMT Time
dGmtDelta = dResult - tmpResult;
FREE_BUFFER(hdlDateTime);
'Return the GMT offset as a number of milliseconds
Return(dGmtDelta);
''If you want to return a string like "GMT -02:00" or "GMT +02:00" for a text display
'if (dGmtDelta>0) then
' sGmtDelta = "GMT +";
'else
' sGmtDelta = "GMT -";
' dGmtDelta = -1 * dGmtDelta;
'end if
'
'dGmtDelta = dGmtDelta + DATETIMEVALUE("01/01/1980","00:00:00" );
'
'sGmtDelta = ADDSTRING(sGmtDelta,DATETIMESTRING(dGmtDelta,"#h"));
'sGmtDelta = ADDSTRING(sGmtDelta,":");
'sGmtDelta = ADDSTRING(sGmtDelta,DATETIMESTRING(dGmtDelta,"#m"));
'
'Return(sGmtDelta);
End Sub
'******************************************************************************************************************************************************
Sub GMTDTDoubleToString(dDateTime)
Dim sResult as str;
'As double format is already GMT, there no problems to convert it to string format
sResult = DATETIMESTRING(dDateTime,"U");
Return(sResult);
End Sub


