I have the following script which reads in an email, parses the subject and creates a calendar appointment from it. Everything works properly except the time when the person is in a different time zone. The time entered in the subject is set as EST/EDT which is why I am subtracting 1 from it to get to CST/CDT which is where our office and servers are. Once I get it to CDT/CST I thought that it would float to reflect the TimeZone of the person opening/receiving the appointment.
The problem that occurs is that when someone in EST/EDT is sent the appointment, it remains scheduled as CDT/CST. The TimeZone is not changing back to reflect their location even though their Location document is set up to use their Operating System Time Zone.
The same problem is happening to people in the PDT/PST time zone. The time zone is not showing the appointment 2 hours earlier.
Does LSLocalTime work as I am expecting and set up the TimeZone to reflect the Time Zone where it is when the document is opened?
Sub Initialize
Dim session As NotesSession
Dim DB As NotesDatabase
Dim NewView As NotesView
Dim Doc As NotesDocument
Dim Object As NotesEmbeddedObject
Dim NewDoc As NotesDocument
Dim vFileNames As Variant
Dim itemA As NotesItem
Set session = New NotesSession
Set db = session.CurrentDatabase
Set NewView = DB.GetView( "($Inbox)" )
Set Doc = NewView.GetFirstDocument
On Error Resume Next
While Not Doc Is Nothing
Dim array As Variant
array = Split( Doc.Subject(0) , "~" )
aDate$ = array(2)
aTime$ = array(3)
Dim notesDateTime As New NotesDateTime( aDate$ & " " & aTime$ )
Call NotesDateTime.AdjustHour( -1 ) 'subtract 1 hour from the appointment time to account for RM setting it to EST/EDT
Set NewDoc = New NotesDocument( db )
NewDoc.From = array(5) 'from the person who sent the note
NewDoc.Form = "Appointment" 'type of calendar entry
'send to mail names
NewDoc.SendTo = array(6)
NewDoc.EnterSendTo = array(6)
NewDoc.Chair = array(6)
NewDoc.altChair = array(6)
'copy to mail names
NewDoc.CopyTo = array(5)
NewDoc.EnterCopyTo = array(5)
'internal fields
NewDoc.AppointmentType = "3"
NewDoc.ExcludeFromView = "D"
Call NewDoc.ReplaceItemValue("_ViewIcon", 64) 'view icon,
NewDoc.MeetingType = "1"
NewDoc.Subject = "Interview for: " & array(1) & " for " & array(0)
NewDoc.tmpOwnerHW = "1"
NewDoc.CalendarDateTime = notesDateTime.LSLocalTime
'start date & time
NewDoc.StartDateTime = notesDateTime.LSLocalTime 'meeting start time - NotesDateTime
NewDoc.StartDate = notesDateTime.DateOnly
NewDoc.StartDate_2 = notesDateTime.DateOnly
NewDoc.StartTime = notesDateTime.TimeOnly
NewDoc.StartTime_2 = notesDateTime.TimeOnly
'adjust end time & date
Call notesDateTime.AdjustHour( Val( Left$( array( 4 ), 1 )))
Call notesDateTime.AdjustMinute( Val( Right$( array( 4 ), 2 )))
'end date & time
NewDoc.EndDateTime = notesDateTime.LSLocalTime 'meeting end time - NotesDateTime
NewDoc.EndDate = notesDateTime.DateOnly
NewDoc.EndDate_2 = notesDateTime.DateOnly
NewDoc.EndTime = notesDateTime.TimeOnly
NewDoc.EndTime_2 = notesDateTime.TimeOnly
NewDoc.TimeRange = Timevalue(NewDoc.StartDateTime(0)) & "-" & Timevalue(NewDoc.EndDateTime(0)) 'length of meeting
'durations
If Val( Left( array(4), 1)) = 0 Then
NewDoc.DispDur_1 = array(4) & " minutes"
NewDoc.DispDur_2 = array(4) & " minutes"
NewDoc.dispDuration_1 = array(4) & " minutes"
Elseif Val( Left( array(4), 1)) = 1 Then
NewDoc.DispDur_1 = array(4) & " hour"
NewDoc.DispDur_2 = array(4) & " hour"
NewDoc.dispDuration_1 = array(4) & " hour"
Else
NewDoc.DispDur_1 = array(4) & " hours"
NewDoc.DispDur_2 = array(4) & " hours"
NewDoc.dispDuration_1 = array(4) & " hours"
End If
NewDoc.tmpStartTime_Local = aDate$ & " - " & aTime$
'nItem
Dim niitem As NotesItem
NewDoc.Alarms = "1"
Set nitem = New NotesItem( NewDoc, "$Alarm", 1)
nitem.IsSummary = True
Set nitem = New NotesItem(NewDoc, "$AlarmDescription", ConfirmName)
nitem.IsSummary = True
Set nitem = New NotesItem(NewDoc, "$AlarmMemoOptions", "")
nitem.IsSummary = True
Set nitem = New NotesItem(NewDoc, "$AlarmOffset", -30)
nitem.IsSummary = True
Set nitem = New NotesItem(NewDoc, "$AlarmUnit", "M")
nitem.IsSummary = True
Set nitem = New NotesItem(NewDoc, "$BusyPriority", "1")
nitem.IsSummary = True
Set nitem = New NotesItem(NewDoc, "BookFreeTime", "0")
nitem.IsSummary = True
Set itemA = doc.GetFirstItem( "Body" )
Call itemA.CopyItemToDocument( NewDoc, "Body" )
Call NewDoc.Save(True,True)
Call NewDoc.Send( False )
Call session.UpdateProcessedDoc( doc )
Call Doc.RemoveFromFolder("($InBox)")
Set Doc = NewView.GetNextDocument ( Doc )
Wend
End Sub
Where am I making the mistake that is forcing the Time Zone to be CST/CDT instead of allowing it to float?