Method: AGI#say_datetime

Defined in:
lib/AGI.rb

#say_datetime(time = Time.now, digits = '""', format = "ABdY", timezone = nil) ⇒ Object

Signals Asterisk to announce the given date and time. If digits are provided as well, will allow the user to terminate the announcement if one of the digits are provided by DTMF. Can accept either a Time object or an integer designation of the number of seconds since 00:00:00 January 1, 1970, Coordinated Universal Time (UTC). Defaults to now.

Returns an AGIResponse including the DTMF digit provided by the channel, if any are.



589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
# File 'lib/AGI.rb', line 589

def say_datetime(time=Time.now, digits='""', format="ABdY", timezone=nil)
  response = AGIResponse.new
  if timezone.nil?
    command_str = "SAY DATETIME #{time.to_i} #{digits} #{format}"
  else
    command_str = "SAY DATETIME #{time.to_i} #{digits} #{format} #{timezone}"
  end
  begin
    response.native = execute(command_str)
  rescue AGITimeoutError, AGICommandError, AGIHangupError
    raise
  end
  if response.native == -1 then
    raise AGIChannelError.new(@last_response, "Channel Failure in (#{command_str})")
  elsif response.native == 0
    response.success = true
  else
    response.success = true
    response.data = response.native.chr
  end
  return response
end