Day in week calculator

made this a while ago never shared

On my calendar, March 1, 2100 is Monday, however, if I say this on your project it's Friday, not Monday. Is it possible to fix?

honestly the equation was taken from google and i dont know if its worth fixing. I will probably fix the code within the next week

i have so many old projects i didnt post

when i enter today's date 2024-04-11 which is Thursday, it comes back as Wednesday?

read above

I actually made a day-in-week-calculator in my calendar project, you can import the block below by dragging that image to the Snap! window:
Snap!Calendar script pic

It's kinda laggy the higher the year but it's 100% guaranteed to give the accurate result.

I actually also did this, taking the algorithm from wikipedia

Where sunday = 1

I was thinking "don't we already have a block for this?" but of course it only tells you today's day of the week. Maybe we need a library block that's just like CURRENT except that it takes a date in some form--days since Unix was invented, I guess--and has the same menu as CURRENT for result options.

And maybe the CURRENT primitive should have a "days since Epoch" option?

I feel like there should just be a (days since ()) block, specifically to add some compatibility to scratch's (days since 2000) block.

Yeah, all the more reason to pin down the form(s) of the input. Plural because it should probably accept a (year, month, date) list, and also a (year, month, date, hour, minute, second, millisecond) list -- basically, any list whose first three items form a date. But also it should accept a number, which should be days since whenever, I guess 2000 would be okay although all the Real Programmers will squirm a little. Or a number too big for that, which should be milliseconds since Epoch, ignoring the beyond-date precision.

And of course this opens the whole can of worms about Julian vs. Gregorian, and how to represent dates BCE, etc. (Tricky because there's no year zero, just positive and negative ones.)

Oh well as usual you just look in the Common Lisp manual and do whatever they do, same as for complex-domain trig functions and such.

That's exactly why I suggested having it as an input. It allows the kids from scratch to be able to convert their projects over (although that block is really only ever used for millisecond timing, as it returns the days and remaining milliseconds).

We aren't understanding each other. You want an input. I agree. Fine. Now, what is that input? A number? If so, it has an implicit origin, even if it's January 1, year 1. You can't have an input saying what the input means; there would be an infinite regress. :~)

Oh yeah, I read that part in your post, but I guess I focused on the "real programmers will squirm a little" part.

You left out the capitalization of "Real Programmers." I guess this is an exception to my argument that upper case is just decorative, but it's in the same category as proper nouns. Real Programmers program in C, stay up all night drinking Mountain Dew, and are male. Whereas real programmers program in Lisp. :~)

I worked on this back in the day

Current blocks
untitled script pic (6)

untitled script pic (7)

If anyone thinks they are missing an option - let me know.

there's also zeller's congruence (this one takes year,month,day as input and returns day of week, 1=sunday)

untitled script pic
untitled script pic (1)

Accurate, fast, and high quality. :+1:

I liked your calculation by the way. I haven't noticed that yet!

thanks. this one i got from the web is sometimes called a variation of zeller's congruence formula.