World Time

World Time

World Time Server shows the current local time and date in cities and countries in all time zones. Xtend IVR allows retrieving the date and time from the time server. The automated IVR assists you to set the time according to the selected location. The user should perform the HTML parsing updations at regular intervals as the web page is subject to change rapidly.

Download the evaluation version of Xtend IVR and install the telephony application in your system. Run the sample script from the Script Editor. Click here to refer the code.

The automated attendant will work as given below:

  • IVR waits for the call
  • Caller dials the number, IVR accepts the call and plays the Welcome message
  • IVR plays the menu and prompts the user to select the location
  • If the location is valid, IVR fetches the time from the world time server and provides the result to the caller
  • If the location is invalid, IVR plays the invalid message
Download the source file zip download for the Internet Application - World Time Server

$key = '<span class="font7">'
$endkey = '</span>'

MAIN:
	display "Waiting for call..."
	answer 1
	display "Call in progress"
	play "welcome.wav"

MENU:
	play "menu.wav"
	$Opt = input(1, 5,,,"123")
	if $Opt = "" then goto MENU
	
	if $Opt = 1
		; India
		$Loc = "IN"
	else if $Opt = 2
		; South Africa
		$Loc = "ZA"
	else if $Opt = 3
		; United Kingdom
		$Loc = "GB"
	endif
	
	
	play "music.wav"    
	play "music.wav"    
	if http(Format("http://www.worldtimeserver.com/time.asp?
						locationid=%s",$Loc)) <> TRUE
		play "error.wav"
		hangup
		goto MAIN
	endif
	clear
	
	
	$pos = Find($http.Page, $key)
	if $pos < 0
		play "error.wav"
		hangup
		goto MAIN
	endif

	$pos += len($key)
	$CurrTime = Mid($http.Page, $pos)
	
	$pos = Find($CurrTime,$endkey)
	if $pos < 0
		play "error.wav"
		hangup
		goto MAIN
	endif
	
	
	$CurrTime = Mid($CurrTime,0,$pos)
	$pos = find($CurrTime,":")
	if $pos < 0
		play "error.wav"
		hangup
		goto MAIN
	endif
	
	$hh = mid($CurrTime,0,$pos)
	$pos += 1
	$mm = mid($CurrTime,$pos)
	$pos = find($mm,' ')
	if $pos < 0
		play "error.wav"
		hangup
		goto MAIN
	endif
	$mm = mid($mm,0,$pos)
	
	$CurrTime = Format("%02d:%02d:00",$hh,$mm)
		
	if $Opt = 1
		play "india.wav"
	elseif $Opt = 2
		play "africa.wav"
	elseif $Opt = 3
		play "uk.wav"
	endif
	play "silence.wav"
	$Val = Time2Wav($CurrTime)
	play $Val
		
	hangup
	goto MAIN


ONHANGUP:
	hangup
	goto MAIN


ONSYSTEMERROR:
	log $error
	display $error
	hangup
	goto MAIN