LOTUSSCRIPT/COM/OLE CLASSES
Examples: NotesDateTime class
1. This script creates a new NotesDateTime object that represents August 18, 1995 at 1:36:22 PM.
Dim dateTime As NotesDateTime
Set dateTime = New NotesDateTime( "08/18/95 01:36:22 PM" )
Messagebox( dateTime.LocalTime )
Messagebox( dateTime.GMTTime )
The script displays the LocalTime property in a dialog box: "08/18/95 01:36:22 PM."
The script displays the GMTTime property in a dialog box: "08/18/95 05:36:22 PM GMT," for example, if the script runs on a computer set to Eastern Standard Time and daylight-saving time is observed; or "08/18/95 06:36:22 PM GMT" if the machine is set to Central Standard Time.
2. This script creates a new NotesDateTime object identical to the one created in the script above.
Dim dateTime As NotesDateTime
Set dateTime = New NotesDateTime( "08-18-95 01:36:22 PM" )
3. This script creates a new NotesDateTime object that represents today's date and then displays a dialog box; for example, if today is August 21, 1995, the script displays "08/21/95" in a dialog box. The time component of the NotesDateTime object is not set.
Dim dateTime As NotesDateTime
Set dateTime = New NotesDateTime( "Today" )
Messagebox( dateTime.LocalTime )
4. This script creates a new NotesDateTime object that represents April 16, 1996 at 20:30. The date component is stored as 08:30:00 PM.
Dim dateTime As New NotesDateTime( "04/16/96 20:30" )
Messagebox( dateTime.LSLocalTime )
Messagebox( dateTime.GMTTime )
The script displays the LocalTime property in a dialog box: "04/16/96 08:30:00 PM."
The script displays the GMTTime property in a dialog box: "04/17/96 03:30:00 AM," for example, if the script runs on a computer set to Pacific Standard Time and daylight-saving time is observed.
5. This script creates two new NotesDateTime objects. The first represents January 15, 1997; the second represents January 15, 2000.
Dim olderDateTime As New NotesDateTime( "01/15/97" )
Dim newerDateTime As New NotesDateTime( "01/15/2000" )
6. This script gets the value of the purgeDate item in a document and places it into a NotesDateTime object. The time zone setting of purgeDate is preserved. For example, if purgeDate has a value of 03/21/96 04:54:33 PM in Eastern Standard Time, the dateTime object represents 03/21/96 04:54:33 PM and its TimeZone property equals 5.
Dim doc As NotesDocument
Dim item As NotesItem
Dim dateTime As NotesDateTime
'...set value of doc...
Set item = doc.GetFirstItem( "purgeDate" )
Set dateTime = item.DateTimeValue
7. This script also gets the value of the purgeDate item in a document, but places it into a variant called value. The LSLocalTime property is then set to value. The time zone setting of purgeDate is not preserved because the LotusScript variant value does not store it. Therefore, the dateTime object might represent 03/21/96 04:54:33, but its TimeZone property defaults to zero.
Dim doc As NotesDocument
Dim item As NotesItem
Dim dateTime As NotesDateTime
Dim value As Variant
'...set value of doc...
Set item = doc.GetFirstItem( "purgeDate" )
Set dateTime = New NotesDateTime( "" )
value = item.Values
dateTime.LSLocalTime = value( 0 )
8. This script sets the Schedule field of the first document in a collection to 09:00 PM. The same value is displayed for both the LocalTime and GMTTime properties. This is because the TimeZone property of the dateTime object defaults to zero when you do not specify both the time and the date in the
dateTime
parameter.
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dateTime As NotesDateTime
Dim c As NotesDocumentCollection
Dim doc As NotesDocument
Dim scheditem As NotesItem
Set db = session.CurrentDatabase
Set dateTime = New NotesDateTime("09:00 PM")
Set c = db.AllDocuments
Set doc = c.GetFirstDocument()
Set scheditem = doc.ReplaceItemValue("Schedule", dateTime)
Call doc.save(True,True)
Messagebox "Local time: " & dateTime.LocalTime & Chr(10) _
& "GMT: " & dateTime.GMTTime
See Also
NotesDateTime class
Glossary
Help on Help
Open Full Help Window
Glossary
Help on Help
Open Full Help Window