I’m newbie on Ruby and I like to know how I can manage to print out the
week numbers(counting from monday or sunday). Till now, I can’t find any
method for it. Can somebody please help.
I’m newbie on Ruby and I like to know how I can manage to print out the
week numbers(counting from monday or sunday). Till now, I can’t find any
method for it. Can somebody please help.
Many Thanks
Dear Ilias,
What you are coming to say.
I can't understand the question fully.
Please express your thoughts what you have in your mind.
or just create the starttime of a week(starting on monday -> for sundy
set wd to Zero)
t = Time.newkw(21) => Mon May 23 01:00:00 +0200 2011
# Fügt der Timeklasse Kalenderwochen beginnend bei Montag ein.
class Time
def kw(wd=1)
kw = self.strftime("%U").to_i
kw -= 1 if self.wday < (wd%7)
return kw
end
def self.newkw(kw=0, year=Time.now.year.to_i, wd=1)
# Gibt Timeobjekt zurück, welches den Start der KW ausgibt
t = Time.local(year)
(0..364).each { |n|
if t.kw(wd) == kw; break; end
t += 3600*24
}
return t
end
end