#wday and #cwday same thing?

D

Daniel Waite

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?
 
D

Daniel Waite

Daniel said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,291
Messages
2,571,455
Members
48,132
Latest member
KatlynC08

Latest Threads

Top