drislands

@[email protected]

This profile is from a federated server and may be incomplete. View on remote instance

Door hinge pin keeps coming up. How to solve?

Looking for help in solving a problem where the lower door hinge pin on my entry door keeps creeping up and causing the deadbolt to become slightly misaligned making it more difficult to lock. Reading online, I keep coming across suggestions of tightening a screw that’s supposed to lock the pin in place but my hinges don’t...

drislands ,

Thanks for trying, SatansMaggotyCumFart.

drislands , (edited )

To break it down a bit further, the code that was provided is specifically trying to get the last day of a month, which I’ll call Month X since it will vary. The code is doing these things, in this order:

  1. Get the month after Month X
  2. If Month X is 12 (aka December) get Month 1 instead (aka January)
  3. Get the Date that is day 1 of the Month from step 2
  4. Get the Date that is one day before the Date from step 3

All this to get the last day of the month from Month X. The reason they did it this way is so they didn’t have to say “Is this February? Then get day 28. Is this January/March/etc? then get day 31.” and so on.

The code that the other user provided will instead get the last day of Month X without having to do all those steps. It’s doing something in the background to get the same data, but the coder doesn’t have to worry about exactly how because they can trust it will work as expected.

It ultimately boils down to the user carving out a round piece of wood, fitting it on an axle and bolting it on, then to find someone already has cheap wheels for sale that are more stable than what they just made.

drislands ,

In the example you gave, wouldn’t the year be off by one when param2.month is 12?

drislands ,

Y’know, I legitimately said to myself “I bet they were writing that from memory and just forgot the edge case. I wonder if that was a problem when doing it originally?” before I wrote that comment. 😂 Time to get some Spock tests set up!

drislands ,

You’re welcome! A big part of coding is finding how other people solved the problems you’re solving and finding how to incorporate their work into yours.

kde , to KDE
@kde@floss.social avatar

One of these 6 beauties will become the wallpaper for Plasma 6. Which one do you prefer?

@kde


Want to contribute to KDE? Become a Supporting Member:

https://kde.org/fundraisers/plasma6member/

Or donate to our community:

https://kde.org/community/donations/

drislands ,

Middle left!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • All magazines