Sha256: 8571f9b3b36fc15a8fa376c835a3091405f5b5a45b00299c81831afe0e2b1872
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
# = Date Select # # code: # George Moschovitis <gm@navel.gr> # # (c) 2004 Navel, all rights reserved. # $Id: select.rb 39 2004-09-29 12:40:53Z elathan $ module N; module UI MONTHS_EN = %w{ - January February March April May June July August September October November December } MONTHS_EL = %w{ - Ιανουαρίου Φεβρουαρίου Μαρτίου Απριλίου Μαϊου Ιουνίου Ιουλίου Αυγούστου Σεπτεμβρίου Οκτωβρίου Νοεμβρίου Δεκεμβρίου } # Date select. # def self.date_select(prefix, day, month, year, yorder = 0, locale = "en") str = "" months = ("en" == locale ? MONTHS_EN : MONTHS_EL) str << %{ <select name="#{prefix}day"> <option value="0">--</option> } for i in (1..31) if i == day str << %{<option value="#{i}" selected="1">#{i}</option>} else str << %{<option value="#{i}">#{i}</option>} end end str << %{ </select> <select name="#{prefix}month"> <option value="0">-------</option> } for i in (1..12) if i == month str << %{<option value="#{i}" selected="1">#{months[i]}</option>} else str << %{<option value="#{i}">#{months[i]}</option>} end end str << %{ </select> <select name="#{prefix}year"> <option value="0">--</option> } nowyear = Time.now.year for i in (0..60) y = yorder < 0 ? nowyear - i : nowyear + i if y == year str << %{<option value="#{y}" selected="1">#{y}</option>} else str << %{<option value="#{y}">#{y}</option>} end end str << %{ </select> } return str end end; end # module
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.1.2 | lib/n/ui/date-select.rb |