Changeset 1206
- Timestamp:
- 2008-10-02 10:36:32 (3 months ago)
- Files:
-
- trunk/app/controllers/application.rb (modified) (2 diffs)
- trunk/lib/parser/lib/rules/zena.rb (modified) (2 diffs)
- trunk/test/helpers/zena_parser/basic.yml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/controllers/application.rb
r1197 r1206 779 779 end 780 780 781 def format_date(thedate, format, tz_name=nil, lang=visitor.lang) 781 def format_date(thedate, theformat = nil, tz_name=nil, lang=visitor.lang) 782 format = theformat || '%Y-%m-%d %H:%M:%S' 782 783 return "" unless thedate 783 784 if tz_name … … 797 798 adate = Date.parse(thedate) 798 799 rescue 799 return "<span class='parser_error'>invalid date #{thedate.inspect}</span>" 800 # only return error if there is a format (without = used in sql query) 801 return theformat ? "<span class='parser_error'>invalid date #{thedate.inspect}</span>" : Time.now.strftime('%Y-%m-%d %H:%M:%S') 800 802 end 801 803 else trunk/lib/parser/lib/rules/zena.rb
r1202 r1206 1642 1642 expand_with(:date=>select) 1643 1643 end 1644 elsif select =~ /^\[(.*)\]$/ 1645 expand_with(:date=>"(#{node_attribute($1)} || main_date)") 1644 elsif select =~ /\[(.*)\]/ 1645 date, static = parse_attributes_in_value(select, :erb => false) 1646 expand_with(:date => "\"#{date}\"") 1646 1647 else 1647 1648 parser_error("bad parameter '#{select}'") … … 3326 3327 elsif ref_date =~ /(\d{4}-\d{1,2}-\d{1,2}( \d{1,2}:\d{1,2}(:\d{1,2})?)?)/ 3327 3328 ref_date = "'#{$1}'" 3329 elsif ref_date =~ /\A"/ 3330 ref_date = "'\#{format_date(#{ref_date})}'" 3328 3331 else 3329 3332 ref_date = "'\#{#{ref_date}.strftime('%Y-%m-%d %H:%M:%S')}'" trunk/test/helpers/zena_parser/basic.yml
r1198 r1206 1105 1105 res: "Sunday 02.03.2008" 1106 1106 1107 date_from_params: 1108 context: 1109 year: 1975 1110 src: "<r:date select='[param:year]-01-01'><r:show date='current_date' format='%A %d.%m.%Y'/></r:date>" 1111 tem: "<%= format_date(\"#{params[:year]}-01-01\", \"%A %d.%m.%Y\") %>" 1112 res: "Wednesday 01.01.1975" 1113 1114 date_from_params_in_query: 1115 context: 1116 year: 2006 1117 src: "<r:date select='[param:year]-01-01'><r:nodes in='site' log='year' do='each' join=', ' do='[name]'/></r:date>" 1118 tem: "/date_format.*format_date.*params\[:year\].*%Y/" 1119 res: "letter, opening, proposition" 1120 1107 1121 paginate: 1108 1122 context:
