MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1x8unz2/forthosetransitioningtotheamericantimeformathereis/phjdb2r/?context=3
r/ProgrammerHumor • u/alexriga • Oct 18 '26
22 comments sorted by
View all comments
Show parent comment
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.
View all comments
Show parent comment
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 ofsis completely unclear, and using a variable to hold the return value is pointlessreturn f'{(hour - 1) % 12 + 1} {'PA'[hour < 12]}M'world_hour > 0 and world_hour < 12: should be0 < world_hour < 12str(world_hour)+" AM": no operator spacing and should bef'{world_hour} AM'elif world_hour > 12: should beelsestr(world_hour-12)+" PM": no operator spacing and should bef'{world_hour - 12} PM'return s_time;: unnecessary semicolon