Advertisement

06.09.2008 at 05:26AM PDT, ID: 23468764
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

how to use time correctly ?

Asked by jujudellago in Ruby Scripting Language

Tags: ,

I am trying to make a simple usage of time fields in a rails 2 application.

my table is very easy, name, synopsis, date, start and end time.

I first designed a table with a start and end date in "datetime" format, but it was too problematic, as for some cases I needed  to have an "open end" event.

I am using the default rails form helper "time_select" for start/end time, it displays correctly the 2 drop down menus, but when the event is saved,the time becomes a full date, saving "18:00" gives a date : 09:18

so the day becomes the hours, the hours becomes the minutes, minutes becomes seconds...

I did not define a specific date format in my environment, can't figure out what's wrong with my ruby :(



Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
# migration
create_table "events", :force => true do |t|
    t.string   "name",                :limit => 255
    t.text     "synopsis"
    t.date     "date"
    t.time     "start_time"
    t.time     "end_time"
    t.boolean  "open_end",  :default => false
  end
 
# _event_form.html.erb   partial
#....
start time: <%=  time_select :event, :start_time %>
end time: <%=  time_select :event, :end_time %>
#....
 
# log on save, I selected "18:00" and "22:30"
 "start_time(1i)"=>"2008", "start_time(2i)"=>"6", "start_time(3i)"=>"9",  "start_time(4i)"=>"18", "start_time(5i)"=>"00", "end_time(1i)"=>"2008",  , "end_time(2i)"=>"6", "end_time(3i)"=>"9", "end_time(4i)"=>"22", "end_time(5i)"=>"30"
 
 
# results in mysql
mysql> select start_time , end_time from events where start_time is not null ;
+------------+----------+
| start_time | end_time |
+------------+----------+
| 09:18:00   | 09:22:30 |
[+][-]06.09.2008 at 05:37AM PDT, ID: 21742672

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 09:48AM PDT, ID: 21744618

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Ruby Scripting Language
Tags: ruby, ruby on rails v2.0.2
Sign Up Now!
Solution Provided By: wesgarrison
Participating Experts: 1
Solution Grade: B
 
 
[+][-]06.16.2008 at 06:17AM PDT, ID: 21793254

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628