# Problem With Formatting

**URL:** <https://rubytalk.org/t/problem-with-formatting/58321>\
**Category:** ruby-talk\
**Created:** [28 April 2010 05:35 UTC](https://rubytalk.org/t/problem-with-formatting/58321 "2010-04-28T05:35:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sourav\_Haldar](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@Sourav\_Haldar](https://rubytalk.org/u/Sourav_Haldar)\
**Post date:** [28 April 2010 05:35 UTC](https://rubytalk.org/t/problem-with-formatting/58321/1 "2010-04-28T05:35:22Z")

</div>

The Below Code is not appropiate if some one explain

Day = 60 \* 60 \* 24

Fromat = "[http://www.google.com](http://www.google.com)" # or any Image Files

t = Time.local(2005, 2, 5)

MWF = [1,3,5]

until t == Time.local(2007, 7, 9)  
&nbsp;&nbsp;if MWF.include? t.wday  
&nbsp;&nbsp;&nbsp;&nbsp;`wget #{t.strftime(Fromat)}`  
&nbsp;&nbsp;&nbsp;&nbsp;sleep 3  
&nbsp;&nbsp;end

&nbsp;&nbsp;t += Day  
end

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Glenn\_Jackman](https://avatars.discourse-cdn.com/v4/letter/g/ce73a5/32.png) [@Glenn\_Jackman](https://rubytalk.org/u/Glenn_Jackman)\
**Post date:** [28 April 2010 15:15 UTC](https://rubytalk.org/t/problem-with-formatting/58321/2 "2010-04-28T15:15:06Z")

</div>

You'll get into trouble with daylight savings time assuming that 1 day =  
86400 seconds:

&nbsp;&nbsp;&nbsp;&nbsp;t = Time.local(2009,11,1) # =\> 2009-11-01 00:00:00 -0500  
&nbsp;&nbsp;&nbsp;&nbsp;day = 60\*60\*24 # =\> 86400  
&nbsp;&nbsp;&nbsp;&nbsp;t + day # =\> 2009-11-01 23:00:00 -0500

To increment by 1 day, use the ActiveSupport gem:

&nbsp;&nbsp;&nbsp;&nbsp;require 'active\_support'  
&nbsp;&nbsp;&nbsp;&nbsp;t + 1.day # =\> 2009-11-02 00:00:00 -0500

> **···**
>
> At 2010-04-28 01:35AM, "Sourav Haldar" wrote:
> 
> > The Below Code is not appropiate if some one explain
> > 
> > Day = 60 \* 60 \* 24
> > 
> > Fromat = "[http://www.google.com](http://www.google.com)" # or any Image Files
> > 
> > t = Time.local(2005, 2, 5)
> > 
> > MWF = [1,3,5]
> > 
> > until t == Time.local(2007, 7, 9)  
> > &nbsp;&nbsp;&nbsp;if MWF.include? t.wday  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`wget #{t.strftime(Fromat)}`  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sleep 3  
> > &nbsp;&nbsp;&nbsp;end
> > 
> > &nbsp;&nbsp;&nbsp;t += Day  
> > end
> 
> --  
> Glenn Jackman  
> &nbsp;&nbsp;&nbsp;&nbsp;Write a wise saying and your name will live forever. -- Anonymous
