Hi all, I got a requirement where i should send mail to user based on the time they set to deliver the mail. In my user table i have notification time which will be saved as 1,2,3,4,5... for options that they select. Now I have the following options- Daily 10Am Daily 3pm Weekly Monday 2PM. So please help me on how to get these values date and time using ruby. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 20 January 2012 09:07, angel david <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I got a requirement where i should send mail to user based on the time > they set to deliver the mail. > > So please help me on how to get these values date and time using ruby.Have you *tried* using an Internet search engine? What results did you get that failed to help you achieve your goal? I just Googled "ruby date time parse string" and got hundreds of results that looked like they would address your problem :-/ -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hey,
I dont have much Idea but I tried this for my application
Police Search. <http://localhost:3000/home#>
t=Time.now
t.split(" ")[3]
you will get the ruby time format
On Fri, Jan 20, 2012 at 2:40 PM, Michael Pavling
<pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> On 20 January 2012 09:07, angel david
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:
> > I got a requirement where i should send mail to user based on the time
> > they set to deliver the mail.
> >
> > So please help me on how to get these values date and time using ruby.
>
> Have you *tried* using an Internet search engine? What results did you
> get that failed to help you achieve your goal?
>
> I just Googled "ruby date time parse string" and got hundreds of
> results that looked like they would address your problem :-/
>
> --
> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On 20 January 2012 09:20, Santosh Kumar Mohanty <santosh-UOy5v6Pi2oC1RDyGVJV6aQ@public.gmane.org> wrote:> > I dont have much Idea > > t=Time.now > t.split(" ")[3] > you will get the ruby time formatAs far as I can see, Time does not respond to ".split" -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
My Dear Friend,
Here is the executed code for time
irb(main):001:0> t=Time.now
=> Fri Jan 20 14:47:46 +0530 2012
irb(main):002:0> t=t.to_s
=> "Fri Jan 20 14:47:46 +0530 2012"
irb(main):003:0> t.split(" ")
=> ["Fri", "Jan", "20", "14:47:46",
"+0530", "2012"]
irb(main):004:0> t.split(" ")[3]
=> "14:47:46"
On Fri, Jan 20, 2012 at 2:54 PM, Michael Pavling
<pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> On 20 January 2012 09:20, Santosh Kumar Mohanty
> <santosh-UOy5v6Pi2oC1RDyGVJV6aQ@public.gmane.org> wrote:
> >
> > I dont have much Idea
> >
> > t=Time.now
> > t.split(" ")[3]
> > you will get the ruby time format
>
> As far as I can see, Time does not respond to ".split"
>
> --
> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On 20 January 2012 09:52, Santosh Kumar Mohanty <santosh-UOy5v6Pi2oC1RDyGVJV6aQ@public.gmane.org> wrote:> Here is the executed code for time > irb(main):001:0> t=Time.now > => Fri Jan 20 14:47:46 +0530 2012 > irb(main):002:0> t=t.to_s > => "Fri Jan 20 14:47:46 +0530 2012" > irb(main):003:0> t.split(" ") > => ["Fri", "Jan", "20", "14:47:46", "+0530", "2012"] > irb(main):004:0> t.split(" ")[3] > => "14:47:46" >So you''ve added a ".to_s" that you didn''t mention before... ;-) But wouldn''t it be easier to do : Time.now.strftime("%T") ? But either way, you''re not addressing the OP, as that was regarding turning String into Time, not Time to String. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
ok!!! cool dude
I got it
we can use like this
str=10 am
t=Time.parse(str)
t.split(" ")[3]
On Fri, Jan 20, 2012 at 3:28 PM, Michael Pavling
<pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> On 20 January 2012 09:52, Santosh Kumar Mohanty
> <santosh-UOy5v6Pi2oC1RDyGVJV6aQ@public.gmane.org> wrote:
> > Here is the executed code for time
> > irb(main):001:0> t=Time.now
> > => Fri Jan 20 14:47:46 +0530 2012
> > irb(main):002:0> t=t.to_s
> > => "Fri Jan 20 14:47:46 +0530 2012"
> > irb(main):003:0> t.split(" ")
> > => ["Fri", "Jan", "20",
"14:47:46", "+0530", "2012"]
> > irb(main):004:0> t.split(" ")[3]
> > => "14:47:46"
> >
>
> So you''ve added a ".to_s" that you didn''t
mention before... ;-)
>
> But wouldn''t it be easier to do :
> Time.now.strftime("%T")
> ?
>
> But either way, you''re not addressing the OP, as that was
regarding
> turning String into Time, not Time to String.
>
> --
> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On 20 January 2012 10:14, Santosh Kumar Mohanty <santosh-UOy5v6Pi2oC1RDyGVJV6aQ@public.gmane.org> wrote:> ok!!! cool dude > > I got it > we can use like thiss> str=10 am You really should try stuff like this before you post it: $ rails c Loading development environment (Rails 3.0.5) ruby-1.8.7-p302 > str=10 am SyntaxError: compile error (irb):1: syntax error, unexpected tIDENTIFIER, expecting $end from (irb):1 ruby-1.8.7-p302 > Colin> t=Time.parse(str) > t.split(" ")[3] > > > On Fri, Jan 20, 2012 at 3:28 PM, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> On 20 January 2012 09:52, Santosh Kumar Mohanty >> <santosh-UOy5v6Pi2oC1RDyGVJV6aQ@public.gmane.org> wrote: >> > Here is the executed code for time >> > irb(main):001:0> t=Time.now >> > => Fri Jan 20 14:47:46 +0530 2012 >> > irb(main):002:0> t=t.to_s >> > => "Fri Jan 20 14:47:46 +0530 2012" >> > irb(main):003:0> t.split(" ") >> > => ["Fri", "Jan", "20", "14:47:46", "+0530", "2012"] >> > irb(main):004:0> t.split(" ")[3] >> > => "14:47:46" >> > >> >> So you''ve added a ".to_s" that you didn''t mention before... ;-) >> >> But wouldn''t it be easier to do : >> Time.now.strftime("%T") >> ? >> >> But either way, you''re not addressing the OP, as that was regarding >> turning String into Time, not Time to String. >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en.-- gplus.to/clanlaw -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.