Sha256: a947fc8165c6d9cb7cdeffbfa1e4dfb8f953c1352612ec9deb50bf142758718c

Contents?: true

Size: 1.53 KB

Versions: 10

Compression:

Stored size: 1.53 KB

Contents

# 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{ - Ιανουαρίου Φεβρουαρίου Μαρτίου Απριλίου Μαϊου Ιουνίου Ιουλίου Αυγούστου Σεπτεμβρίου Οκτωβρίου Νοεμβρίου Δεκεμβρίου }	

	# Generate a component that allows the user to select a day. 
	#
	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

10 entries across 10 versions & 1 rubygems

Version Path
nitro-0.10.0 lib/nitro/ui/date-select.rb
nitro-0.2.0 lib/n/ui/date-select.rb
nitro-0.3.0 lib/n/ui/date-select.rb
nitro-0.4.1 lib/nitro/ui/date-select.rb
nitro-0.8.0 lib/nitro/ui/date-select.rb
nitro-0.9.3 lib/nitro/ui/date-select.rb
nitro-0.9.5 lib/nitro/ui/date-select.rb
nitro-0.7.0 lib/nitro/ui/date-select.rb
nitro-0.5.0 lib/nitro/ui/date-select.rb
nitro-0.6.0 lib/nitro/ui/date-select.rb