Method: Palaver::Calendar#show

Defined in:
lib/palaver/calendar.rb

#showObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/palaver/calendar.rb', line 26

def show
  day, month, year =
    if @default_date then [ @default_date.day, @default_date.month, @default_date.year]
    else [ 0, 0, 0 ]
    end
  chosen_date = nil
  with_tempfile do |tfpath|
    cmd = 'dialog --calendar "%s" %d %d %d %d %d 2> %s' % [ @text,
                                                            @height, @width, 
                                                            day, month, year,
                                                            tfpath ]
    success = system cmd
    chosen_date = Date.strptime(File.read(tfpath), "%d/%m/%Y") if success
  end
  return chosen_date
end