PugJesus@lemmy.world to memes@lemmy.worldEnglish · 5 months agoThe last hopelemmy.worldexternal-linkmessage-square33fedilinkarrow-up1830arrow-down15
arrow-up1825arrow-down1external-linkThe last hopelemmy.worldPugJesus@lemmy.world to memes@lemmy.worldEnglish · 5 months agomessage-square33fedilink
minus-squareodium@programming.devlinkfedilinkarrow-up3·5 months agoThat program better be using an existing date library, because otherwise it’s most definitely wrong.
minus-squareasyncrosaurus@programming.devlinkfedilinkarrow-up3·edit-25 months agopublic string GetDayOfWeek(DateTime date) => "saturday"; I also calculated it, his result checks out.
minus-squareal4s@lemmy.worldlinkfedilinkarrow-up4·5 months agoDon’t be ridiculous, that would never pass QA. But this one will. Joy for years to come: public string GetDayOfWeek(DateTime date) { return ((date - new DateTime(1970, 1, 1)).Milliseconds / 86400000) % 7 switch { 0 => "Thursday", 1 => "Friday", 2 => "Saturday", 3 => "Sunday", 4 => "Monday" }; }
That program better be using an existing date library, because otherwise it’s most definitely wrong.
public string GetDayOfWeek(DateTime date) => "saturday";
I also calculated it, his result checks out.
Don’t be ridiculous, that would never pass QA.
But this one will. Joy for years to come: