Sha256: 013605e96748b265cfe9a04269f2ec0cf2eedb1a415c75203d8aff637e39dd7a

Contents?: true

Size: 1.52 KB

Versions: 5

Compression:

Stored size: 1.52 KB

Contents

# * George Moschovitis  <gm@navel.gr>
# (c) 2004-2005 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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nitro-0.11.0 lib/nitro/ui/date-select.rb
nitro-0.12.0 lib/nitro/ui/date-select.rb
nitro-0.13.0 lib/nitro/ui/date-select.rb
nitro-0.14.0 lib/nitro/ui/date-select.rb
nitro-0.15.0 lib/nitro/ui/date-select.rb