#wday and #cwday same thing?

The documentation for #wday says that the start-of-week is Sunday.
#cwday says the start-of-week is Monday.

However, in IRB, both methods return the same value. Today is Tuesday
for me, and they’re both returning 2. I’m not sure if it’s considering
Sunday or Monday as its start, because I dunno if it returns 0 for
start-of-week or 1. The doc makes it sound like it would start at 0, but
that’s not something I want to gamble with.

Anyone know what’s going on?

Daniel W. wrote:

The documentation for #wday says that the start-of-week is Sunday.
#cwday says the start-of-week is Monday.

However, in IRB, both methods return the same value. Today is Tuesday
for me, and they’re both returning 2. I’m not sure if it’s considering
Sunday or Monday as its start, because I dunno if it returns 0 for
start-of-week or 1. The doc makes it sound like it would start at 0, but
that’s not something I want to gamble with.

Anyone know what’s going on?

Ah, I see. Start-of-week for #wday is 0, and #cwday is 1. So they will
appear to be in sync until you reach each method’s end-of-week, in
which #wday end its run at 6, starting over again at 0. #cwday on the
other hand, ends at 7 and begins its run at 1.

Yay.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs