You don’t even need to convert anything if they meant 5am.
Wish there was a toggle for it like there is on phones
Submitted 3 weeks ago by renzev@lemmy.world to [deleted]
https://lemmy.world/pictrs/image/4b5b9045-4877-4a9c-9f2d-45c7755780b3.png
Comments
Kolanaki@yiffit.net 3 weeks ago
Aurenkin@sh.itjust.works 3 weeks ago
Why’d you have to say 5AM instead of just 5? Now I need to convert it to 24h time
synae@lemmy.sdf.org 3 weeks ago
Yea, you just disown them as a friend and easily away
A real friend would never make you do something that early
NegativeLookBehind@lemmy.world 3 weeks ago
5+12
Or
17-2, drop the 1
renzev@lemmy.world 3 weeks ago
yeah, adding twelve to a single-digit number really does make my brain freeze like that. Something something can’t do math under pressure.
NegativeLookBehind@lemmy.world 3 weeks ago
That’s OK, champ.
JustAnotherKay@lemmy.world 3 weeks ago
This might help you: you’re not adding 12 to a single-digit number. Just do 2 + x then throw a 1 in front, or add 10. Whichever is easier to conceptualize. (Where x is the single-digit number, in case that needed clarifying)
sleen@lemmy.zip 3 weeks ago
(5+2) + 10
RememberTheApollo_@lemmy.world 3 weeks ago
After a while there is no conversion necessary. 5 pm is 5 pm is 17:00. They are the same. UTC to local however can get fucked. Time zone variables, daylight standard/savings variables, no thanks.
sxan@midwest.social 3 weeks ago
Yeah, I never found adding 12 to or from a number to be particularly challenging. Still, I do wish AM/PM would go away, not to mention DST. Can’t escape UTC and time zones, though, not reasonably, anyway. If for no other reason than doing the conversion makes you aware of how inconvenient your suggested meeting time is for the other party.
IDKWhatUsernametoPutHereLolol@lemmy.dbzer0.com 3 weeks ago
Disclaimer: I am not a programmer, I have no idea if my “code” is written in the correct format.
Zagorath@aussie.zone 3 weeks 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
bandwidthcrisis@lemmy.world 3 weeks ago
What is this? Some sort of COBOL or something.
IDKWhatUsernametoPutHereLolol@lemmy.dbzer0.com 3 weeks ago
Idk its my non-programmer’s impression of what code lools like, sorry if its incorrect 😅
LwL@lemmy.world 3 weeks 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 3 weeks 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).