this post was submitted on 21 Apr 2024
708 points (97.1% liked)

Programmer Humor

32318 readers
207 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 28 points 6 months ago (3 children)

I spent way too long today figuring out why my app was doing something that it's NOT supposed to do on weekends.

I read Luxon's docs (pretty cool lib tbh) again and again, and tried everything I could think of to get isWeekend to return a sane result.

Turns out I was pulling a somewhat older version of Luxon, where isWeekend didn't exist. In any sane language, I expect I'd get a huge warning about a property that doesn't exist, but alas...

Typescript helps me keep my sanity, but juuuuust barely.

[–] [email protected] 20 points 6 months ago* (last edited 6 months ago)

If isWeekend doesn't exist, then the weekend doesn't exist, so it's naturally false.

That's why JavaScript gets pushed so hard - it's part of the capitalist agenda to keep us working 7 days a week

[–] [email protected] 7 points 6 months ago

That's fair. Typescript has to cook with the existing js ecosystem.

[–] [email protected] 5 points 6 months ago (2 children)

Weren't you getting runtime errors for the function not being found?

[–] [email protected] 2 points 6 months ago (1 children)

I don't know how luxon works, but isWeekend could be a property instead of a function

[–] [email protected] 2 points 6 months ago

It is. It also happens to be undefined, and checking that for truth is how I was bitten.