Share via


Obtaining and Validating Dates

  Microsoft Speech Technologies Homepage

(Application Speech Control Sample)

This sample illustrates the use of the Date and CompareValidator Application Speech Controls.

The Date control in this sample is programmed to recognize a date in the past. The application recognizes fully-specified dates such as "March 3rd, 1970" and "The 19th of October, 1962." The application also recognizes incomplete dates such as "June 19th" or "The 16th," and sets the missing parameters as follows:

  • If the user does not specify a month, and the specified day number is greater than the current day number, the application sets the month parameter to the previous month.
  • If the user does not specify a month, and the specified day number is less than or equal to the current day number, the application sets the month parameter to the current month.
  • If the user does not specify a year, the application sets the year parameter to the most recent year value (either the current year or the previous year) that will yield a date in the past given the specified month and day.

Assume the current date is September 25, 2002. The following table illustrates how the application interprets incompletely specified dates.

If the user says:       The application sets the date to:
The 24th September 24, 2002
September 24th September 24, 2002
September 26th September 26, 2001
The 26th August 26, 2002

Note  Number values must be spelled out when using the text input feature of Telephony Application Simulator (TASim). For example, when using text input for the examples in the previous table, type "The twenty fourth", "September twenty sixth", "September twenty sixth", and "The twenty sixth".

  • Using the DateContext property (set in this sample to Past).
  • Implementation of a complex confirmation process that can range from a global confirmation of the whole item, to the confirmation of individual date entities, depending on user input.

Running the Sample

  1. Open the sample. The application prompts the user for a date of birth.
  2. Say a date that occurred any time after 1901, but before the current date. If the specified birth date is for a day before January 1, 1902, or for a future date, the application prompts the user to supply a valid date. For example, if the current date is September 25, 2002, invalid dates would include September 24, 1901, and September 26, 2002.
  3. After the application recognizes a valid date, it speaks the date.

Remarks

  • The application does no recognize invalid dates such as February 29th, 2001 or April 31st.
  • The global command "Help" is available at any time.

See Also

Application Speech Controls | Command Control | CustomValidator Control | SemanticMap Control | AutoPostBack Property | BargeIn Property | ClientValidationFunction Property | FallbackCount Property | Operator Property | PromptSelectFunction Property | QuestionPrompt Property | RejectThreshold Property | Scope Property | SemanticItemToValidate Property | Type Property | ValueToCompare Property | XPathTrigger Property