MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1x8unz2/forthosetransitioningtotheamericantimeformathereis/phfyl21/
r/ProgrammerHumor • u/alexriga • Oct 18 '26
22 comments sorted by
View all comments
16
where's the humor? this is just the most dogshit python i've ever seen in my life
-2 u/SeaNational3797 Oct 18 '26 This is incredibly readable and you’re wrong for not liking it 3 u/Makonede Oct 18 '26 as_time: the parameter is already a time, so the function name is unclearworld_hour=world_hour: terrible shadowing of a global variable of the exact same name for literally no reasons_time: meaning of s is completely unclear, and using a variable to hold the return value is pointlessthe conditional chain should be condensed into a format string such as return f'{(hour - 1) % 12 + 1} {'PA'[hour < 12]}M'world_hour > 0 and world_hour < 12: should be 0 < world_hour < 12str(world_hour)+" AM": no operator spacing and should be f'{world_hour} AM'elif world_hour > 12: should be elsestr(world_hour-12)+" PM": no operator spacing and should be f'{world_hour - 12} PM'return s_time;: unnecessary semicolon 0 u/laplongejr Oct 26 '26 I guess python's standard are different but as a Java dev I think OP's version was easier to read than the format string. -10 u/alexriga Oct 18 '26 to me the rules are funny, coming from “military style.”If midnight: 12 AMIf night/morning: X AMbut what comes after 11:59 AM? Not 12 AM, 12 PM!what about after 12:59 PM? Well, of course, 1 PM!It’s the reason many people often mistake 12 AM and PM if they’re unfamiliar with this system. 10 u/Makonede Oct 18 '26 none of that has anything to do with programming -11 u/alexriga Oct 18 '26 I used code to express it, I figured that would count. 6 u/Makonede Oct 18 '26 rule 1 3 u/Kyrros Oct 18 '26 Or you could use date library 1 u/rosuav Oct 18 '26 str(hour % 12 or 12) + ("PM" if hour >= 12 else "AM")
-2
This is incredibly readable and you’re wrong for not liking it
3 u/Makonede Oct 18 '26 as_time: the parameter is already a time, so the function name is unclearworld_hour=world_hour: terrible shadowing of a global variable of the exact same name for literally no reasons_time: meaning of s is completely unclear, and using a variable to hold the return value is pointlessthe conditional chain should be condensed into a format string such as return f'{(hour - 1) % 12 + 1} {'PA'[hour < 12]}M'world_hour > 0 and world_hour < 12: should be 0 < world_hour < 12str(world_hour)+" AM": no operator spacing and should be f'{world_hour} AM'elif world_hour > 12: should be elsestr(world_hour-12)+" PM": no operator spacing and should be f'{world_hour - 12} PM'return s_time;: unnecessary semicolon 0 u/laplongejr Oct 26 '26 I guess python's standard are different but as a Java dev I think OP's version was easier to read than the format string.
3
as_time
world_hour=world_hour
s_time
s
return f'{(hour - 1) % 12 + 1} {'PA'[hour < 12]}M'
world_hour > 0 and world_hour < 12
0 < world_hour < 12
str(world_hour)+" AM"
f'{world_hour} AM'
elif world_hour > 12
else
str(world_hour-12)+" PM"
f'{world_hour - 12} PM'
return s_time;
0 u/laplongejr Oct 26 '26 I guess python's standard are different but as a Java dev I think OP's version was easier to read than the format string.
0
I guess python's standard are different but as a Java dev I think OP's version was easier to read than the format string.
-10
to me the rules are funny, coming from “military style.”
It’s the reason many people often mistake 12 AM and PM if they’re unfamiliar with this system.
10 u/Makonede Oct 18 '26 none of that has anything to do with programming -11 u/alexriga Oct 18 '26 I used code to express it, I figured that would count. 6 u/Makonede Oct 18 '26 rule 1 3 u/Kyrros Oct 18 '26 Or you could use date library 1 u/rosuav Oct 18 '26 str(hour % 12 or 12) + ("PM" if hour >= 12 else "AM")
10
none of that has anything to do with programming
-11 u/alexriga Oct 18 '26 I used code to express it, I figured that would count. 6 u/Makonede Oct 18 '26 rule 1
-11
I used code to express it, I figured that would count.
6 u/Makonede Oct 18 '26 rule 1
6
rule 1
Or you could use date library
1
str(hour % 12 or 12) + ("PM" if hour >= 12 else "AM")
View all comments
16
u/Makonede Oct 18 '26
where's the humor? this is just the most dogshit python i've ever seen in my life