Class: Time
- Inherits:
-
Object
- Object
- Time
- Defined in:
- lib/Common/Fixnum.rb
Instance Method Summary collapse
Instance Method Details
#round(res = 'd') ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# 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) ⇒ Object
25 26 27 28 29 |
# 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 ⇒ Object
22 23 24 |
# File 'lib/Common/Fixnum.rb', line 22 def wday_non_gb wday==0 ? 6 : wday-1 end |