Trouble - DST - Creating Entries on calendar

Hi, Guys

I decided to ask for help because I’m almost giving up. I’ve been working on this for some days and it’s driving me crazy…so, let’s go…

I have a document with appointment information. When an user presses the button “Submit”, it saves the document (course form) and creates a Calendar Entry on user’s calendar. The part of creation of the entry is working, but the trouble is to set the right time…

For example: The course information has the following date/time information:

Start Time: April, 13, 2011

End Time: April, 14, 2011

Start Time: 2:00 PM EDT

End Time: 5:00 PM EDT

What must be set on my calendar (Brazil, GMT - 3)?

Start Time: 3:00 PM ZW3 → Only one hour after EDT

End Time: 6:00 PM ZW3

What is Notes setting on my calendar? (WRONG)

Star Time: 4:00 PM ZW3 → Two hours after EDT (is not considering DST properties)

End Time: 7:00 PM ZW3

I mean, the time of the course will be always on Eastern time. The problem is that when the calendar entry is created, Notes does not recognize the DST properties, so the time information on the entry is wrong.

I hope I was understandable…

Do you have any idea? if you prefer, I can post my code here.

Thanks for any help/idea you can give me,

Queila

Subject: post your code

Subject: Troubles DST - Creating a calendar entry using Lotus Script

Hi,

First of all, thanks for trying to help me. Below you can see my code, which is in the Submit action of the form.

I have some fields validations, please don’t consider it. The user is setting the date and Time on a text Field, and that is why I need to format everything to get a valid Date Time.

Example of date: “April 11-15”

Example of time: “9:00 AM - 12:00 PM Eastern”

Sub Click(Source As Button)

Dim session As New NotesSession	

Dim workspace As New NotesUIWorkspace

Dim starttime, dataIni As Variant

Dim endtime As Variant

Dim db As notesDatabase	

Dim uidoc As NotesUIDocument

Dim thisDoc, calEntry As NotesDocument

Dim mailDatabase As NotesDatabase

Dim mailDoc As NotesDocument



Set db = session.CurrentDatabase

Set uidoc = workspace.CurrentDocument

Set ThisDoc = uidoc.Document



'Getting information about user's mail server and path

Set mailDatabase = New NotesDatabase("", "")

Call mailDatabase.OpenMail

’ Set MailDoc = New NotesDocument(Maildatabase)

'MailDoc.Form = "Appointment"



'Fields validation

If Len(thisDoc.Out1(0)) = 0 Then

	Messagebox "Please click the Retrieve Bluepage Record", MB_OK, db.Title

	continue = False

	Exit Sub

End If



If Len(thisDoc.SessionName(0)) = 0 Then

	Messagebox "Please click the 'Select Session' to select a session you would like to attend.", MB_OK, db.Title

	continue = False

	Exit Sub

End If



'Start Date and End Date

Dim monthCourse As String

Dim monthNumber As Integer

Dim startDay As Integer

Dim endDay As Integer

Dim vetDays As Variant

Dim vetTime As Variant

Dim startT, endT, startPeriod, endPeriod, zone As String



'Getting Date information

vetData = Split(thisDoc.SessionDate(0), " ")

If Instr(thisDoc.sessionDate(0), "-" ) Then

	monthCourse = vetData(0)

	vetDays = Split(vetData(1), "-")

	startDay = vetDays(0)

	endDay = vetDays(1)		

Else

	monthCourse = vetData(0)	

	startDay = vetData(1)

End If



'Getting time information

vetTime = Split(thisDoc.SessionTime(0), " ")

startT = vetTime(0)

startPeriod = vetTime(1)

endT = vetTime(3)

endPeriod = vetTime(4)

zone = vetTime(5)



'Getting number related to the month

Select Case monthCourse

Case "January":

	monthNumber = 1

Case "February":

	monthNumber = 2		

Case "March": 

	monthNumber = 3	

Case "April": 

	monthNumber = 4

Case "May": 

	monthNumber = 5

Case "June": 

	monthNumber = 6

Case "July": 

	monthNumber = 7

Case "August": 

	monthNumber = 8

Case "September": 

	monthNumber = 9

Case "October": 

	monthNumber = 10

Case "November": 

	monthNumber = 11

Case "December": 

	monthNumber = 12				

End Select



If Instr(thisDoc.sessionDate(0), "-" ) Then

	'Configuration of the initial date of the course

	dataIni = 	Datenumber(ThisDoc.sessionYear(0), monthNumber, startDay)

     'Configuration of the final date of the course

	dataFim = Datenumber(ThisDoc.sessionYear(0), monthNumber, endDay)

	ndias = (DataFim - DataIni) + 1 'Course duration	

Else

	'Configuration of the initial date of the course

	dataIni = 	Datenumber(ThisDoc.sessionYear(0), monthNumber, startDay)

     'Configuration of the final date of the course

	dataFim = DataIni

	ndias = 1	

End If



Select Case zone

Case "Eastern":

	zone = "EDT" 'Eastern is in DST now

End Select



HoraIni = startT & " " & startPeriod & " " & zone 'Start Time of the appointment

HoraFim = endT & " " & endPeriod & " " & zone 'End Time of the appointment



For i = 1 To ndias 'This loop will create a calendar Entry for each course day

	

	calEntryStartTimeStr = DataIni & " " & HoraIni 'Date and Start Time of the entry Calendar

	calEntryEndTimeStr = DataIni & " " & HoraFim 'Date and End Time of the entry Calendar

	

	Dim arrDt As Variant

	Dim arrDtxt As Variant

	

    ' create the calendar entry document

	Set calEntry  =  New NotesDocument(mailDatabase)

	

    'This sets appointment fields

	calEntry.Subject = ThisDoc.sessionName(0)

	calEntry.Location = ThisDoc.sessionLoc(0)

	calEntry.Body = ThisDoc.sessionDescript(0)

	Set calEntryStartTime = New NotesDateTime(calEntryStartTimeStr)

	Set calEntryEndTime = New NotesDateTime(CalEntryendTimeStr)

	calEntry.From = thisDoc.From

	calEntry.Form = "Appointment"

	calEntry.StartTimeZone = "Z=5$DO=1$DL=3 2 1 11 1 1$ZX=30$ZN=Eastern"

	calEntry.EndTimeZone = "Z=5$DO=1$DL=3 2 1 11 1 1$ZX=30$ZN=Eastern"

	Select Case calEntryType

	Case "Appointment"

		calEntry.AppointmentType = "0"

		Call calEntry.ReplaceItemValue("_ViewIcon", 160)

	Case "Event"

		calEntry.AppointmentType = "2"

		Call calEntry.ReplaceItemValue("_ViewIcon", 9)

	Case "Reminder"

		calEntry.AppointmentType = "4"

		Call calEntry.ReplaceItemValue("_ViewIcon", 10)

	End Select

	

	calEntry.CHAIR = session.UserName     

	calEntry.StartDateTime = calEntryStartTime.LSLocalTime

	calEntry.EndDateTime = calEntryEndTime.LSLocalTime

	calEntry.CalendarDateTime = calEntryStartTime.LSLocalTime

	calEntry.TimeRange = Timevalue(calEntry.StartDateTime(0)) & "-" & _

	Timevalue(calEntry.EndDateTime(0))

	calEntry.ExcludefromView = "D"

	calEntry.BookFreetime = ""

	Call calEntry.AppendItemValue("$BusyName", session.UserName)

	Call calEntry.AppendItemValue("$BusyPriority", "1")

	Call calEntry.AppendItemValue("$NoPurge", Timevalue(calEntry.EndDateTime(0)))

	Call calEntry.AppendItemValue("$PublicAccess", "1")

	

	Call calEntry.Save(False, False)

’ If markPrivate Then Call calEntry.AppendItemValue(“OrgConfidential”, “1”)

	Dim uical As NotesUIDocument

	Set uical =  workspace.EditDocument(True, calEntry)

	Call uical.refresh()

	Call uical.save

	Call uical.close

	

	DataIni = DataIni + 1

Next



Call uidoc.Save



Messagebox "Your enrollment information has been saved.", MB_OK, db.Title

Call uidoc.Close

End Sub

Thanks!!

Queila