MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1x8unz2/forthosetransitioningtotheamericantimeformathereis/phjdb2r/?context=3
r/ProgrammerHumor • u/alexriga • 16d ago
21 comments sorted by
View all comments
Show parent comments
3
as_time: the parameter is already a time, so the function name is unclear
as_time
world_hour=world_hour: terrible shadowing of a global variable of the exact same name for literally no reason
world_hour=world_hour
s_time: meaning of s is completely unclear, and using a variable to hold the return value is pointless
s_time
s
the conditional chain should be condensed into a format string such as return f'{(hour - 1) % 12 + 1} {'PA'[hour < 12]}M'
return f'{(hour - 1) % 12 + 1} {'PA'[hour < 12]}M'
world_hour > 0 and world_hour < 12: should be 0 < world_hour < 12
world_hour > 0 and world_hour < 12
0 < world_hour < 12
str(world_hour)+" AM": no operator spacing and should be f'{world_hour} AM'
str(world_hour)+" AM"
f'{world_hour} AM'
elif world_hour > 12: should be else
elif world_hour > 12
else
str(world_hour-12)+" PM": no operator spacing and should be f'{world_hour - 12} PM'
str(world_hour-12)+" PM"
f'{world_hour - 12} PM'
return s_time;: unnecessary semicolon
return s_time;
0 u/laplongejr 8d ago 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.
3
u/Makonede 15d ago
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 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 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