search for: to_time

Displaying 20 results from an estimated 33 matches for "to_time".

2009 Jun 18
3
Date.new.to_time.to_i
What''s going on here!? >> Date.new.to_time.to_i NoMethodError: undefined method `to_i'' for Mon, 01 Jan -4712 00:00:00 -0800:DateTime from (irb):25 >> Date.today.to_time.to_i => 1245308400 >> RUBY_VERSION => "1.8.7" >> Rails.version => "2.1.1" (I''m not sure if this is...
2006 May 16
10
Date verus Time class
I''m using the date_select and datetime_select helpers in my view, and they return Date classes from the params hash. But how do I work with Date classes, they don''t print human readable dates or times, Time classes work well I can use strftime("%H:%M") to print to the screen. Is it possible to convert a Date to a Time, Ive been tinkering in irb but have got
2006 May 24
0
distance_of_time_in_german_words
...german language. Basically I copied the definition of the rails builtin distance_of_time_in_words and extracted another method german_words_for_distance_in_seconds. Just put these e.g. into module ApplicationHelper and you can use it in all views. def distance_of_time_in_german_words(from_time, to_time = 0, include_seconds = false) from_time = from_time.to_time if from_time.respond_to?(:to_time) to_time = to_time.to_time if to_time.respond_to?(:to_time) distance_in_seconds = ((to_time - from_time).abs).round german_words_for_distance_in_seconds(distance_in_seconds) end def...
2007 May 05
0
to_time "time out of range"
Hello, I''m experiencing some inconsistent results between code I run in the console and in my test/project code. On the console this works... >> Date.new(1899, 12, 25).to_time => Fri Dec 13 14:45:52 CST 1901 >> Date.new(2058, 12, 25).to_time => Mon Jan 18 21:14:07 CST 2038 The values are changed to their min and max values. If I do the same in my test or development code, I get an exception... ArgumentError: time out of range Why would the conversion work...
2008 Jun 14
0
Bug and patch for vpim-0.619
On Sat, Jun 14, 2008 at 10:42 AM, Christopher J. Bottaro <cjbottaro at alumni.cs.utexas.edu> wrote: > I noticed two little bugs when using your vpim module in a Rails application. > > 1) The vpim module overwrites Rail''s implementation of Date#to_time. > 2) The vpim module''s implementation of Date#to_time causes > Date.today.to_time to return a Time that is a day in the past. > > I don''t know how to fix issue 2, but I have attached a small patch > that makes vpim''s Date#to_time use any existing implemen...
2007 Feb 21
2
date helper bug?
...= "2007/02/21 09:54:00" => "2007/02/21 09:54:00" # see what the helper gives me... (about 1 hour difference from Time.now) >> helper.time_ago_in_words(nine_54) => "about 9 hours" # looking at date_helper.rb I see that parameters passed in are called with to_time method... >> nine_54.to_time => Wed Feb 21 09:54:00 UTC 2007 >> Time.now.to_time => Wed Feb 21 11:04:34 Pacific Standard Time 2007 # A ha! So we''re off by the difference in time zones between PST and UTC (GMT?). So poking around a bit more... >> Time.parse(nine_54)...
2010 Nov 12
1
Dashboard throwing undefined method `to_time' for nil:NilClass error on page view
...is2.10] [2010-11-12 11:51:18] INFO WEBrick::HTTPServer#start: pid=3348 port=3000 Processing PagesController#home (for 192.168.0.20 at 2010-11-12 11:51:54) [GET] Parameters: {"action"=>"home", "controller"=>"pages"} NoMethodError (undefined method `to_time'' for nil:NilClass): app/models/status.rb:7:in `initialize'' app/models/status.rb:76:in `new'' app/models/status.rb:76:in `execute'' app/models/status.rb:76:in `map'' app/models/status.rb:76:in `execute'' app/models/status.rb:66:in `by_int...
2007 Sep 24
3
Oracle Date + RoR
Hi Experts, I''ve a model called Product where i''ve column called created_at, updated_at where i''ve made a query based on Oracle date format like date_of_created = ''23-SEP-07'' @product = Product.find(:all, :conditions => ["created_at=?", date_of_created]) but in view its empty. AND EXPERTS I''VE DATA WITH 24-SEP-07 FOR MORE
2008 Jun 08
20
how to parse a "dd/mm/yyyy" formatted date string???
Hi, I''m stuck. How do you parse a "dd/mm/yyyy" formatted date string??? I get a date format error. Thanks in advance Greg --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to
2006 Jan 22
8
Date Calculation
I am trying to calculate the number of days between 2 dates using Time.now - object.date where object.date is a date pulled from a database. I want to display the age of the entry in the database in days. I keep getting an error about not being able to convert a date into a float. What am I doing wrong. If I use object.date - object.date it seems to work but the answer is useless (0). I
2008 May 03
11
Date comparisons
I occasionally get this error: 1) ''A puzzle once featured, should no longer be nominated'' FAILED expected: Sun May 04 09:10:26 -0700 2008, got: Sun May 04 09:10:26 -0700 2008 (using ==) ./spec/models/puzzle_spec.rb:180: So, the dates looks the same to me. Any ideas for how to debug? Joe
2006 Mar 01
3
Convert Date to Time
Hi, How do i convert a Date to a Time?? I have a date returned from sql and i need to be able to use handy functions like next_week or beggining of week. Any help appreciated Thanks, Chris -- Posted via http://www.ruby-forum.com/.
2006 Aug 06
1
How to query with calculations?
Hi, I would like to do something simple yet I''m confused. Lets say I have a table with 2 fields: rank, updated_at. I would like to show all records matching this condition: rank = rank ? (Time.now.to_time ? Updated_at.to_time) As you can see this is supposed to be a calculation on the field. How do I write a query to show this? I''ve tried with_scope, and regular find but did not succeed. Please advice Thanks Adi -- Posted via http://www.ruby-forum.com/.
2006 Jul 14
1
Converting Date string to Time Object
Hi, I have MySQL model with created_on specified as :date. This means that the day the record was created on is stored in the database as a string like "2006-04-28". I want to be able output a something like "5 days ago". From looking in the API I''ve found "strftime" and "*distance_of_time_in_words*". Distance_of_time_in_words only accepts Time
2006 Jun 12
3
compare Date with TIme
Hi When returning data from a database column set as a date field I get ''2006-06-06'' I am then have these two lines of code in my controller, taht gain the date I require. pNow = Time.now @pDate = Time.local(pNow.year, pNow.month, 1) At the monment one is set to a date data type while one is set to a Time data type. how can i change these to be the same data type so i can
2006 Apr 02
2
Problem with RSS feed from Rails Recipes
I''m trying to add an RSS feed to my app, and am going through the Rails Recipes chapter on doing so. I get the following error when I request the feed: undefined method `gmtime'' for #<DateTime: 1963061961/800,0,2299161> ... 7: xml.pubDate CGI.rfc1123_date(@posts.first.created_on) Any idea what''s up? Pat
2005 Mar 09
21
Converting time retrieved from MySQL
I''m having a problem converting a date retrieved from my MySQL database and I''m hoping someone can help. MySQL stores the date/time as this: 2005-03-08 17:00:34.0 and according to my Pickaxe book Ruby stores times as "the number of seconds and microseconds since [...] January 1, 1970". All well and good. Unfortunately, RoR is converting my date to this:
2007 Dec 12
6
Add a month to a Date object
Howdy all, This may be the dumbest question in the world, but how can you "add one month" to a Date object? I can''t just add 30 days, because months have varying lengths. Any help would be much appreciated... Thanks! -Neal --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2006 Jan 16
8
[newbie] This Month / Next Month / The One After That
What I want to do is simple. I''d like code that prints out the name of this month (January) the next month (February) and the one after that (March) I''ve been able to print this month: <% t = Time.now %> <%= t.strftime(" This Month is: %B") %> But I can''t figure out how to get the next months to print out! -- Posted via
2006 Oct 19
3
Selecting datetime values from SQL Server (year < 1970)
....1.6. Any AR find() call that generates a SELECT * type query against a table with a DATETIME column in SQL Server whose value occurs before 1970 will fail, because of the coercion of SQL Server datetime types to Time values in Ruby. See sqlserver_adapter.rb line 490 (record[col] = record[col].to_time if record[col].is_a? DBI::Timestamp) If I remove the coercion (just commenting out that line), I can successfully execute these find() calls. I have a couple of questions: 1) Does anyone know of any adverse effects that I will incur by doing this? 2) Does anyone know when this will be resolved...