class Time

Public Instance Methods

round(res='d') click to toggle source
# File lib/Common/Fixnum.rb, line 30
def round(res='d')
        #res can be H=hour,d=day,W=week
        #Time.gm(0,0,res=="H" ? hour : 0,day,month,year)#,yday - (res=="W" ? wday_non_gb : 0),false)
        m=month
        y=year
        if res=="W"
                if day <= wday_non_gb
                        t=Time.at(self-7*24*60*60)
                        d=t.day
                        m=t.month
                        y=t.year
                else
                        d=day - wday_non_gb
                end
        else
                d=day
        end
        Time.mktime(y, m, d, res=="H" ? hour : 0)
end
strftime_w(str) click to toggle source
# File lib/Common/Fixnum.rb, line 25
def strftime_w(str)
        s=str.clone
        s.sub!("%W",(strftime("%W").to_i+1).to_s) if str.include?("%W")
        strftime(s)
end
wday_non_gb() click to toggle source
# File lib/Common/Fixnum.rb, line 22
def wday_non_gb
        wday==0 ? 6 : wday-1
end