'Returns the ticks value of the given date and time with the specified time zone offset.
'The last parameter is the time zone offset measured in hours.
Public Sub SetDateAndTime2(Years As Int, Months As Int, Days As Int, Hours As Int, Minutes As Int, Seconds As Int, _
TimeZone As Double) As Long
Dim df As String = DateTime.DateFormat
DateTime.DateFormat = "GGyyyyMMddHHmmssz"
Dim d As String = Format(Abs(Years), 4) & Format(Months, 2) & Format(Days, 2)
d = GetEra(Years < 0) & d
Dim tzMinutes As Int = Abs(TimeZone * 60)
Dim tzHours As Int = tzMinutes / 60
Dim tzSign As String
If TimeZone >= 0 Then tzSign = "+" Else tzSign = "-"
d = d & Format(Hours, 2) & Format(Minutes, 2) & Format(Seconds, 2) & _
"GMT" & tzSign & Format(tzHours, 2) & ":" & Format(tzMinutes Mod 60, 2)
Try
Dim ticks As Long = DateTime.DateParse(d)
Catch
DateTime.DateFormat = df
Log("Error: Invalid value: " & d)
Return "invalid date" + 1 'hack to throw an error
End Try
DateTime.DateFormat = df
Return ticks
End Sub