title: Ruby Date Calculation
body: <p>This is not a problem so much as something I noticed and was wondering if someone could explain it to me.</p>
  
  <p>If I use inline-type syntax I get two different, interchanging, answers:</p>
  
  <pre><code>irb(main):017:0&gt; d = (Date.today &gt;&gt; 3) - (d.day + 1)
  =&gt; #&lt;Date: 2013-06-01 ((2456445j,0s,0n),+0s,2299161j)&gt;
  irb(main):018:0&gt; d = (Date.today &gt;&gt; 3) - (d.day + 1)
  =&gt; #&lt;Date: 2013-06-03 ((2456447j,0s,0n),+0s,2299161j)&gt;
  irb(main):019:0&gt; d = (Date.today &gt;&gt; 3) - (d.day + 1)
  =&gt; #&lt;Date: 2013-06-01 ((2456445j,0s,0n),+0s,2299161j)&gt;
  irb(main):020:0&gt; d = (Date.today &gt;&gt; 3) - (d.day + 1)
  =&gt; #&lt;Date: 2013-06-03 ((2456447j,0s,0n),+0s,2299161j)&gt;
  </code></pre>
  
  <p>If I do the same on multiple lines I get the same correct answer every time:</p>
  
  <pre><code>irb(main):025:0&gt; d = Date.today
  =&gt; #&lt;Date: 2013-03-05 ((2456357j,0s,0n),+0s,2299161j)&gt;
  irb(main):026:0&gt; d = d &gt;&gt; 3
  =&gt; #&lt;Date: 2013-06-05 ((2456449j,0s,0n),+0s,2299161j)&gt;
  irb(main):027:0&gt; d = d - d.day + 1
  =&gt; #&lt;Date: 2013-06-01 ((2456445j,0s,0n),+0s,2299161j)&gt;
  irb(main):028:0&gt; d = Date.today
  =&gt; #&lt;Date: 2013-03-05 ((2456357j,0s,0n),+0s,2299161j)&gt;
  irb(main):029:0&gt; d = d &gt;&gt; 3
  =&gt; #&lt;Date: 2013-06-05 ((2456449j,0s,0n),+0s,2299161j)&gt;
  irb(main):030:0&gt; d = d - d.day + 1
  =&gt; #&lt;Date: 2013-06-01 ((2456445j,0s,0n),+0s,2299161j)&gt;
  </code></pre>
  
  <p>Any ideas why this would happen? I am just interested to understand because, the way I see it, both ways should always return the same answer.</p>