<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-6930361.post4840941297025135351..comments</id><updated>2011-03-31T12:22:58.917-04:00</updated><title type='text'>Comments on Platte daddy: Calculate next weekday in Ruby on Rails</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://daddy.platte.name/feeds/4840941297025135351/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default'/><link rel='alternate' type='text/html' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html'/><author><name>Ryan Platte</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6930361.post-8938859496343174242</id><published>2011-03-31T12:22:58.917-04:00</published><updated>2011-03-31T12:22:58.917-04:00</updated><title type='text'>Thanks for posting this.

I made a version that fi...</title><content type='html'>Thanks for posting this.&lt;br /&gt;&lt;br /&gt;I made a version that finds the next weekday.&lt;br /&gt;ex: Time.next(:monday)&lt;br /&gt;&lt;br /&gt;https://gist.github.com/896635</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/8938859496343174242'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/8938859496343174242'/><link rel='alternate' type='text/html' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html?showComment=1301588578917#c8938859496343174242' title=''/><author><name>Spooner</name><uri>http://www.blogger.com/profile/15540402267543073687</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html' ref='tag:blogger.com,1999:blog-6930361.post-4840941297025135351' source='http://www.blogger.com/feeds/6930361/posts/default/4840941297025135351' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1386821993'/></entry><entry><id>tag:blogger.com,1999:blog-6930361.post-1907722971726976915</id><published>2010-08-02T10:29:29.519-04:00</published><updated>2010-08-02T10:29:29.519-04:00</updated><title type='text'>Since I found this by google, I&amp;#39;ll add one mor...</title><content type='html'>Since I found this by google, I&amp;#39;ll add one more bit though the post is old. This is without a loop:&lt;br /&gt;&lt;br /&gt;def nextweekday(original_date)&lt;br /&gt;  wday = original_date.wday&lt;br /&gt;  original_date + 1 + (wday/5)*(7-wday)&lt;br /&gt;end</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/1907722971726976915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/1907722971726976915'/><link rel='alternate' type='text/html' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html?showComment=1280759369519#c1907722971726976915' title=''/><author><name>Noel</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html' ref='tag:blogger.com,1999:blog-6930361.post-4840941297025135351' source='http://www.blogger.com/feeds/6930361/posts/default/4840941297025135351' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-963993700'/></entry><entry><id>tag:blogger.com,1999:blog-6930361.post-4758325875415667824</id><published>2009-03-09T19:09:00.000-04:00</published><updated>2009-03-09T19:09:00.000-04:00</updated><title type='text'>This seems to be working for me...&lt;br&gt;&lt;br&gt;original...</title><content type='html'>This seems to be working for me...&lt;BR/&gt;&lt;BR/&gt;original_date += 1.days until (1..5).member?(original_date.wday)&lt;BR/&gt;&lt;BR/&gt;This is just a refactor of the previous comment, please feel free to let me know if it is incorrect!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/4758325875415667824'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/4758325875415667824'/><link rel='alternate' type='text/html' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html?showComment=1236640140000#c4758325875415667824' title=''/><author><name>Shane</name><uri>http://www.everydayblog.net</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html' ref='tag:blogger.com,1999:blog-6930361.post-4840941297025135351' source='http://www.blogger.com/feeds/6930361/posts/default/4840941297025135351' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1887125786'/></entry><entry><id>tag:blogger.com,1999:blog-6930361.post-6756354332617330179</id><published>2007-11-09T14:39:00.000-05:00</published><updated>2007-11-09T14:39:00.000-05:00</updated><title type='text'>def next_weekday (timeobj)&lt;br&gt;  begin&lt;br&gt;  timeobj...</title><content type='html'>def next_weekday (timeobj)&lt;BR/&gt;  begin&lt;BR/&gt;  timeobj += (60*60*24)&lt;BR/&gt;  end until timeobj.wday != 6 &amp;&amp; timeobj.wday != 0&lt;BR/&gt;  timeobj&lt;BR/&gt;end&lt;BR/&gt;&lt;BR/&gt;a tiny revision to actually make this work...</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/6756354332617330179'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/6756354332617330179'/><link rel='alternate' type='text/html' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html?showComment=1194637140000#c6756354332617330179' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html' ref='tag:blogger.com,1999:blog-6930361.post-4840941297025135351' source='http://www.blogger.com/feeds/6930361/posts/default/4840941297025135351' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-75349898'/></entry><entry><id>tag:blogger.com,1999:blog-6930361.post-6682967312087545626</id><published>2007-09-29T03:56:00.000-04:00</published><updated>2007-09-29T03:56:00.000-04:00</updated><title type='text'>Here's a slightly more concise version &lt;br&gt;&lt;br&gt;def...</title><content type='html'>Here's a slightly more concise version &lt;BR/&gt;&lt;BR/&gt;def next_weekday (timeobj)&lt;BR/&gt;  begin&lt;BR/&gt;    timeobj += (60*60*24)&lt;BR/&gt;  end until timeobj != 6 &amp;&amp; timeobj != 0&lt;BR/&gt;  timeobj&lt;BR/&gt;end&lt;BR/&gt;&lt;BR/&gt;&lt;BR/&gt;Because the until condition is at the end that loop will run once, adding one day, no matter what. If the next day is a weekday it quits and returns the day. &lt;BR/&gt;&lt;BR/&gt;If it's not a weekday it will loop until it hits the next monday and then return the day. Hopefully this is handy for someone out there!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/6682967312087545626'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/6682967312087545626'/><link rel='alternate' type='text/html' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html?showComment=1191052560000#c6682967312087545626' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html' ref='tag:blogger.com,1999:blog-6930361.post-4840941297025135351' source='http://www.blogger.com/feeds/6930361/posts/default/4840941297025135351' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-2118049700'/></entry><entry><id>tag:blogger.com,1999:blog-6930361.post-8358489780816626120</id><published>2007-03-01T16:13:00.000-05:00</published><updated>2007-03-01T16:13:00.000-05:00</updated><title type='text'>Stephen, Ruby's Date implementation is very heavyw...</title><content type='html'>Stephen, Ruby's Date implementation is very heavyweight for day-to-day use (it handles lots of odd cases in past dates, different calendars, etc.), so it's much less used than Time. I wrote this for a Rails app, where Time is the standard way to represent a date.&lt;BR/&gt;&lt;BR/&gt;But you're absolutely right that this code doesn't check its assumption. Good point.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/8358489780816626120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/8358489780816626120'/><link rel='alternate' type='text/html' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html?showComment=1172783580000#c8358489780816626120' title=''/><author><name>Ryan Platte</name><uri>http://www.blogger.com/profile/09026929741729187984</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html' ref='tag:blogger.com,1999:blog-6930361.post-4840941297025135351' source='http://www.blogger.com/feeds/6930361/posts/default/4840941297025135351' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-793944253'/></entry><entry><id>tag:blogger.com,1999:blog-6930361.post-9034359331977453034</id><published>2007-03-01T16:11:00.000-05:00</published><updated>2007-03-01T16:11:00.000-05:00</updated><title type='text'>Had I learned to read as a young child I would hav...</title><content type='html'>Had I learned to read as a young child I would have noticed you did specify that this was a Time object.&lt;BR/&gt;&lt;BR/&gt;I would still recommend adding a check on the object being passed though.&lt;BR/&gt;&lt;BR/&gt;Something along the lines of &lt;BR/&gt;one_day = 60 * 60 * 24 if original_date.class == Time else one_day = 1&lt;BR/&gt;&lt;BR/&gt;Just in case some n00b like myself tried to throw a Date at it figuring that this method was intended to work on a date based on your choice of parameter name.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/9034359331977453034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/9034359331977453034'/><link rel='alternate' type='text/html' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html?showComment=1172783460000#c9034359331977453034' title=''/><author><name>Stephen</name><uri>http://www.blogger.com/profile/01960818788446736837</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html' ref='tag:blogger.com,1999:blog-6930361.post-4840941297025135351' source='http://www.blogger.com/feeds/6930361/posts/default/4840941297025135351' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1258447102'/></entry><entry><id>tag:blogger.com,1999:blog-6930361.post-3908877116932380856</id><published>2007-03-01T15:40:00.000-05:00</published><updated>2007-03-01T15:40:00.000-05:00</updated><title type='text'>Nice code with a small flaw.&lt;br&gt;&lt;br&gt;When doing add...</title><content type='html'>Nice code with a small flaw.&lt;BR/&gt;&lt;BR/&gt;When doing addition on a date in ruby with the '+' symbol, one day is equal to the integer 1.  Instead of using one_day = 60 * 60 * 24, use 1.  That is assuming you are using a Date object for original_date.  If you are using a Time object for original_date your code is correct for generating the same time at the next weekday. You might want to add code to this method to check the class type of the object being passed in to be on the safe side.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/3908877116932380856'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/3908877116932380856'/><link rel='alternate' type='text/html' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html?showComment=1172781600000#c3908877116932380856' title=''/><author><name>Stephen</name><uri>http://www.blogger.com/profile/01960818788446736837</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html' ref='tag:blogger.com,1999:blog-6930361.post-4840941297025135351' source='http://www.blogger.com/feeds/6930361/posts/default/4840941297025135351' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1258447102'/></entry><entry><id>tag:blogger.com,1999:blog-6930361.post-1361806712500106574</id><published>2006-12-22T13:06:00.000-05:00</published><updated>2006-12-22T13:06:00.000-05:00</updated><title type='text'>Here&amp;#39;s my crack at it. :-)

def next_weekday(o...</title><content type='html'>Here's my crack at it. :-)&lt;br /&gt;&lt;br /&gt;def next_weekday(original_date)&lt;br /&gt;  one_day = 60 * 60 * 24&lt;br /&gt;  result = original_date + one_day&lt;br /&gt;  original_date.wday == 5 &amp;&amp; result += one_day * 2&lt;br /&gt;  result&lt;br /&gt;end</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/1361806712500106574'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6930361/4840941297025135351/comments/default/1361806712500106574'/><link rel='alternate' type='text/html' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html?showComment=1166810760000#c1361806712500106574' title=''/><author><name>logic</name><uri>http://www.blogger.com/profile/18124558793142592579</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://esm.logic.net/media/images/eclipse/me/enginebay-small.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://daddy.platte.name/2006/12/calculate-next-weekday-in-ruby-on-rails.html' ref='tag:blogger.com,1999:blog-6930361.post-4840941297025135351' source='http://www.blogger.com/feeds/6930361/posts/default/4840941297025135351' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-300604940'/></entry></feed>
