Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Trouble advancing date in iterator
Peter Marks
11/27/2007 11:35:00 PM
I am trying to assemble an array of month names called
"names_of_months_paid":
0 first_month_paid = client.first_month_paid
1 names_of_months_paid = []
2 number_of_months_paid.times do
3 names_of_months_paid << first_month_paid.strftime("%B")
4 first_month_paid >> (1)
5 end
For each payment ("number_of_months_paid"), I need to store the name of
the month, then store the name of the next month starting from
"first_month_paid". I seem to be having trouble advancing the month of
"first_month_paid" on line 4 as I am left with an array of first month
names. How might I get this to work?
--
Posted via
http://www.ruby-...
.
2 Answers
Robert Dober
11/28/2007 10:52:00 AM
0
On Nov 28, 2007 12:34 AM, Peter Marks <petertmarks@gmail.com> wrote:
> I am trying to assemble an array of month names called
> "names_of_months_paid":
>
> 0 first_month_paid = client.first_month_paid
> 1 names_of_months_paid = []
> 2 number_of_months_paid.times do
> 3 names_of_months_paid << first_month_paid.strftime("%B")
> 4 first_month_paid >> (1)
> 5 end
>
> For each payment ("number_of_months_paid"), I need to store the name of
> the month, then store the name of the next month starting from
> "first_month_paid". I seem to be having trouble advancing the month of
> "first_month_paid" on line 4 as I am left with an array of first month
> names. How might I get this to work?
> --
> Posted via
http://www.ruby-...
.
>
>
irb(main):020:0> t=Time::now
=> Wed Nov 28 11:50:38 +0100 2007
irb(main):021:0> t.month
=> 11
irb(main):022:0> Date::MONTHNAMES[t.month]
=> "November"
irb(main):023:0> m = 12
=> 12
irb(main):024:0> Date::MONTHNAMES[(m % 12 ).succ]
=> "January"
irb(main):025:0> m = 1
=> 1
irb(main):026:0> Date::MONTHNAMES[(m % 12 ).succ]
=> "February"
HTH
Robert
--
http://ruby-smalltalk.blo...
---
All truth passes through three stages. First, it is ridiculed. Second,
it is violently opposed. Third, it is accepted as being self-evident.
Schopenhauer (attr.)
Peter Marks
11/28/2007 7:42:00 PM
0
Thanks for your suggestions Robert. Looks like this is all I needed to
do:
4 first_month_paid = first_month_paid >> (1)
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Trouble advancing date in iterator
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password