What is this? Some sort of COBOL or something.
Comment on Wish there was a toggle for it like there is on phones
IDKWhatUsernametoPutHereLolol@lemmy.dbzer0.com 1 week ago
If "am/pm indicator" = "pm" AND "hour" =/= "12" ADD "12" to "hour" Else Ignore the am/pm indicator, time is correct in 24 hour format.
Disclaimer: I am not a programmer, I have no idea if my “code” is written in the correct format.
bandwidthcrisis@lemmy.world 1 week ago
IDKWhatUsernametoPutHereLolol@lemmy.dbzer0.com 1 week ago
Idk its my non-programmer’s impression of what code lools like, sorry if its incorrect 😅
AliasVortex@lemmy.world 1 week ago
We call that pseudocode and it looks fine to me. No computer will run it natively (AI meat grinders aside), but most devs will be able to pick up on the logic and convert it to actual code.
Disclaimer: am a programmer
ScrollerBall@lemmy.world 1 week ago
My favorite is the fact that Microsoft intentionally left a bug in Excel that treats 1900 as a leap year when it wasn’t so they could maintain compatability with Lotus 1-2-3. And at this point fixing it would cause nearly every date value in excel files to display as off by one day and break a bunch of date formulas.
weker01@sh.itjust.works 1 week ago
Can confirm Source: am a grammerpro
b000rg@midwest.social 1 week ago
This is honestly exactly what programming is: breaking down big problems into step by step simple problems. If you’ve never considered taking up programming before, I’d suggest you try it sometime and see where it takes you. It’s not hard to learn, it just takes time.
vinyl@lemmy.world 1 week ago
You should program
bandwidthcrisis@lemmy.world 1 week ago
COBOL is an old language Internet to make programs look a bit like English descriptions of what was needed.
I don’t really know it, but your code reminded me of the idea of it.
Don’t worry if your code is incorrect, just make random changes until you hit on something that no longer results in errors :)
LwL@lemmy.world 1 week ago
If only this was true, but for some reason midnight is 12 am. And noon is 12 pm (I’m aware that the reason is that 12:00:00.00001 is in the second half of the day. I just think it should be called 0 pm).
sxan@midwest.social 1 week ago
Midnight is 00:00 is 12am. They accounted for 12pm, but need to subtract 12 if it’s 12am.
So, you’d do away with 12 entirely and make AM/PM 0-based: 00:00am - 11:59am, and then 00:00pm - 11:59pm? Makes sense if you’re a programmer, but 0 is a fairly recent invention, and most daily measuring concepts are fundamentally 1-based. Heck, we couldn’t even get all programming languages to agree on 0-based array indexing (looking at you, MATLAB, and you, bash).
Zagorath@aussie.zone 1 week ago
As far as pseudocode goes, this is pretty damn good. The main thing I’d change is that things in “quotes” generally represent strings, i.e. literal text. Variable names usually don’t have quotes around them. That’s a universal enough trait of real programming languages that it would almost never not transfer to pseudocode. Also, numbers intended to be read as numbers don’t typically have quotes.
How I would change this accordingly
If am_pm_indicator = “pm” AND hour =/= 12 ADD 12 to hour Else Ignore the am/pm indicator, time is correct in 24 hour format. # Leaving this as-is because it’s more like a comment than code anyway