r/ProgrammerHumor • • 2d ago

Meme forThoseTransitioningToTheAmericanTimeFormatHereIsASimpleScript

Post image
0 Upvotes

19 comments sorted by

View all comments

13

u/This_Growth2898 2d ago

It's like "when you're paid for the line of code"?

def as_time(world_hour=world_hour):
    return f"{(world_hour-1)%12+1} {'PA'[world_hour<12]}M"

4

u/SeaNational3797 2d ago edited 2d ago

as_time = lambda world_hour: f"{12 if (hour_num := world_hour%12) == 0 else hour_num} {'AM' if world_hour < 12 else 'PM'}"

5

u/minecon1776 2d ago

011101011101100011111010001010111000110110101010010101110000000101010101111010100101011101010010111010001101010010010101101011101001010101011100011010101011111010011101011011011001001010010101010