CwDateTimePicker CwDateTimePicker provides a simple and intuitive interface through which to exchange date and time information with a user. For example, with this control you can ask the user to enter a date and then easily retrieve the selection. Several protocols exist to get and set the control’s value; the other group of protocols specify the appearance and behavior of the control. Protocol Value getters and setters date Answer the day month and year of the receiver as aDate. date: aDate Set the day month and year of the receiver from aDate. date: aDate time: aTime Set the day, month and year of the receiver from aDate and the hour, minute and second of the receiver from aTime. dateAndTime Answer the day, month, year, hour, minute and second of the receiver as aDateAndTime. dateAndTime: aDateAndTime Set the day, month, year, hour, minute and second of the receiver from aDateAndTime. day answer the day of the calendar day: set the day of the calendar hour answer the hour of the clock hour: set the hour of the clock minute answer the minute of the clock minute: set the minute of the clock month answer the month of the calendar month: set the month of the calendar second answer the second of the clock second: set the second of the clock time Answer the hour, minute and second of the receiver as aTime. time: aTime Set the hour, minute and second of the receiver from aTime. year answer the year of the calendar year: set the year of the calendar Look and Feel displayFormat Answer the format to use in displaying the date and time value of the control. • XmSHORT - month and year; • XmMEDIUM - month day and year; • XmLONG day of week together with month day and year; • XmTIME - hours minutes and seconds. • ‘a custom format string’ (see Date and Time Picker Format Strings for valid content) The default is XmLONG. displayFormat: Set the format to use in displaying the date and time value of the control. • XmSHORT - month and year; • XmMEDIUM - month day and year; • XmLONG day of week together with month day and year; • XmTIME - hours minutes and seconds. • ‘a custom format string’ (see Date and Time Picker Format Strings for valid content) isDropdown Answer true if a month calendar is available to select the date. Answer false if a spin button is available to choose selected portions of the date. The default is to set the value using the month calendar dropdown. isDropdown: aBoolean Set the manner in which users select the receiver’s value. • true if a month calendar is available to select the date. • false if a spin button is available to choose selected portions of the date. isShownone Answer whether the widget displays a check box that is automatically selected whenever a date is picked or entered. If the check box is subsequently deselected, the application cannot retrieve the date from the control because, in essence, the control has no date. The default is false. isShownone: aBoolean Set whether whether the widget displays a check box that is automatically selected whenever a date is picked or entered. If the check box is subsequently deselected, the application cannot retrieve the date from the control because, in essence, the control has no date. none Answer whether to return no value: the state for no-value checkbox. The default is false. none: aBoolean Set whether to return no value. Date and Time Format Strings A format string consists of a series of elements each of which defines how to display a particular piece of the date and time value. The format elements are displayed in the order they appear in the format string and are replaced by the actual date and time. The following groups of characters specifies how to display the various pieces of a date and time value. Element Description "d" The one- or two-digit day. "dd" The two-digit day. Single-digit day values are preceded by a zero. "ddd" The three-character weekday abbreviation. "dddd" The full weekday name. "h" The one- or two-digit hour in 12-hour format. "hh" The two-digit hour in 12-hour format. Single-digit values are preceded by a zero. "H" The one- or two-digit hour in 24-hour format. "HH" The two-digit hour in 24-hour format. Single-digit values are preceded by a zero. "m" The one- or two-digit minute. "mm" The two-digit minute. Single-digit values are preceded by a zero. "M" The one- or two-digit month number. "MM" The two-digit month number. Single-digit values are preceded by a zero. "MMM" The three-character month abbreviation. "MMMM" The full month name. "t" The one-letter AM/PM abbreviation (that is, AM is displayed as "A"). "tt" The two-letter AM/PM abbreviation (that is, AM is displayed as "AM"). "yy" The last two digits of the year (that is, 1996 would be displayed as "96"). "yyyy" The full year (that is, 1996 would be displayed as "1996"). In addition to elements which are replaced by the value of a time and date picker, text can be shown in the control. This is done by adding text to the format string within single quotes. Spaces and punctuation marks do not need to be quoted. Note Nonformat characters that are not delimited by single quotes will result in unpredictable display by the control. Example 1: To display a date with the format "'Today is: 04:22:31 Tuesday Mar 23, 1996", the format string is "'Today is: 'hh':'m':'s dddd MMM dd', 'yyyy". Example 2: "'Don''t forget' MMM dd',' yyyy" produces output that looks like: Do not forget Mar 23, 1996. It is not necessary to use quotes with the comma, so "'Don''t forget' MMM dd, yyyy" is also valid, and produces the same output. Callbacks and Events The date and time picker has no callbacks or events specific to it. Example datePicker := CwDateTimePicker createWidget: 'DateTimePicker' "$NON-NLS$" parent: workWindow argBlock: nil. datePicker manageChild. datePicker setValuesBlock: [:w |w leftAttachment: XmATTACHFORM; rightAttachment: XmATTACHFORM; topAttachment: XmATTACHFORM; width: 100; height: 22; hour: 15; minute: 17; second: 48; displayFormat: 'dddd H:mm']. datePicker addCallback: XmNvalueChangedCallback receiver: self selector: #valueChanged:clientData:callData: clientData: nil.