Aryk Grosz
2007-Oct-31 18:52 UTC
Time/Date prior to 1970 into negative milliseconds/seconds
Anyone know how to take a date or time prior to 1970 and convert it into negative seconds or milliseconds? I know there is time.to_i, but a Time object can''t be prior to 1970 or else it will throw an error. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
gene tani
2007-Oct-31 21:18 UTC
Re: Time/Date prior to 1970 into negative milliseconds/seconds
On Oct 31, 11:52 am, Aryk Grosz <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Anyone know how to take a date or time prior to 1970 and convert it into > negative seconds or milliseconds? > > I know there is time.to_i, but a Time object can''t be prior to 1970 or > else it will throw an error. > -- > Posted viahttp://www.ruby-forum.com/.ActiveSupport Time#to_date http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Time/Conversions.html#M000327 you should be aware that SQL server and Oracle have had gotchas concerning Date and Datetime objects, tho i don''t recall specifics now. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
gene tani
2007-Oct-31 21:29 UTC
Re: Time/Date prior to 1970 into negative milliseconds/seconds
On Oct 31, 2:18 pm, gene tani <gene.t...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Oct 31, 11:52 am, Aryk Grosz <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > Anyone know how to take a date or time prior to 1970 and convert it into > > negative seconds or milliseconds? > > > I know there is time.to_i, but a Time object can''t be prior to 1970 or > > else it will throw an error. > > -- > > Posted viahttp://www.ruby-forum.com/. > > ActiveSupport Time#to_datehttp://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Time/... > > you should be aware that SQL server and Oracle have had gotchas > concerning Date and Datetime objects, tho i don''t recall specifics > now.BTW: Oracle and SQLserver: http://dev.rubyonrails.org/ticket/3430 http://blog.rayapps.com/2007/08/27/how-to-explicitly-set-oracle-date-column-as-ruby-date-attribute/ --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Aryk Grosz
2007-Nov-01 00:14 UTC
Re: Time/Date prior to 1970 into negative milliseconds/secon
Right, Im aware of the to_date function, but that returns a date object. What im trying to do is a take a Date object occurring before 1970 and convert it into negative milliseconds/seconds. so I want the resulting value to be a negative integer. So what you are showing me doesnt work unless you can craft a simple proof of concept using those functions. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Tyler MacDonald
2007-Nov-01 00:28 UTC
Re: Time/Date prior to 1970 into negative milliseconds/secon
Aryk Grosz <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> What im trying to do is a take a Date object occurring before 1970 and > convert it into negative milliseconds/seconds.This will do seconds: irb(main):005:0> require "date" => true irb(main):006:0> d = Date.parse("1950-01-01") => #<Date: 4866565/2,0,2299161> irb(main):007:0> d.strftime("%s") => "-631152000" irb(main):008:0> d.strftime("%s").to_i => -631152000 Cheers, Tyler --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Aryk Grosz
2007-Nov-01 05:19 UTC
Re: Time/Date prior to 1970 into negative milliseconds/secon
Thanks Tyler, you''re awesome. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---