Yes, someone actually did this and I found it running on our server

33 points

Ok another US local units are retarded rant: it’s called weekEND! why do you start your week at sunday and not monday! Sunday is part of the weekEND!

permalink
report
reply
9 points

If you’re referring to an “end” of an object, it can refer to the extreme of a side of it. For example, aglets are at either end of a shoelace.

permalink
report
parent
reply
4 points
*

I’m refering to end in a temporal sense because we are talking about a time context here. There is a clear direction so going backwards brings you to the begin.

permalink
report
parent
reply
3 points

I’m English, not American but I see it as Saturday and Sunday are the two ends of the week. Like how a string has two ends. The weekend is both the start and the finishing end of the week.

permalink
report
parent
reply
1 point

since we are in a temporal context here i would argue that there is a clear distrinction between beginning and end here

permalink
report
parent
reply
2 points
*

End doesn’t always have to be the latter side of something though like I said earlier with the string analogy. The start is also an end.

permalink
report
parent
reply
10 points

So, when someone asks if you are free the next two weekends, you assume they’re talking about the next Saturday (tail weekend) and the next Sunday (front weekend)?

permalink
report
parent
reply
-1 points

No, the two ends of a week create a singular weekend.

permalink
report
parent
reply
56 points

You want to expand your business to Europe. Bam, your code is broken, in Europe the week starts on Monday.

Than you want to expand to the middle east. Bam, broken again… Because in arab countries and Israel, the weekend is on Friday and Saturday.

Then you want to expand to Mexico and India. Bam, broken again, their weekend is only on Sunday.

permalink
report
reply
6 points

This dude(ette) globalizes.

permalink
report
parent
reply
7 points

Not using CultureInfo.InvariantCulture for basically everything

permalink
report
parent
reply
23 points

The obvious solution is to inject an IWeekendDaysOfWeekProvider service in the inversion of control container. In your, uh, javascript web app.

permalink
report
parent
reply
1 point

This but non-ironically.

permalink
report
parent
reply
15 points
*

Just npm install isWeekend for the required locales.

Depends on: isMonday, isTuesday,…

permalink
report
parent
reply
2 points

…isWednesdayMyDudes…

permalink
report
parent
reply
5 points

I was wondering why the second example returned monday and tuesday. I had no idea the week could start any day other than monday

permalink
report
parent
reply
24 points

Interesting that your days are 1-indexed. What happens on nullday?

permalink
report
reply
3 points

Reserved for future use

permalink
report
parent
reply
2 points

Undefined

permalink
report
parent
reply
9 points

Zat is vhen ve party!

permalink
report
parent
reply
74 points
*

As a Real Programmer™ I have developed such a deep fear of anything time and date related that I would fully endorse dispatching an API call to the tz_database instead of attempting any fucking part of this.

Kids, it’s fine to meme about silly stuff… but date and time is deadly serious, regardless of how careful you think you’re being you are wrong.

Do you know how many timezones there are in Indiana? No? Look it up and scream in horror.

permalink
report
reply
1 point
*
permalink
report
parent
reply
3 points

2 timezones but the complication is that it is dependent on which country you’re in?

permalink
report
parent
reply
4 points

There are two distinct time offsets used in Indiana but there are 11 different timezones https://en.m.wikipedia.org/wiki/Time_in_Indiana

permalink
report
parent
reply
9 points

Here’s a fun thought experiment: What gregorian year and date will the spacian date value of zero correlate to? Trick question.

The atomic clock on the moon and every other celestial body colonized will simply start at zero, and thanks to relativity it will not actually be the same rate of time passing as on earth.

Enjoy your nightmares.

permalink
report
parent
reply
7 points

Luckily we won’t colonize the moon or another planet anytime soon…

permalink
report
parent
reply
1 point
Deleted by creator
permalink
report
parent
reply
5 points
*

IMO every datetime should be in utc, and variables for datetimes should either be suffixed “Utc” or have a type indicating their time zone (DateTimeOffset or UtcDateTime etc). Conversion to local time happens at the last possible second (e.g. in the view model or an outbound http request parameter). Of course that doesn’t solve the problem of interoperating with other morons programmers who don’t follow these rules, but it keeps things a lot neater locally.

Scheduling based on regional time conventions (holidays, weekends, etc) is just not great though.

permalink
report
parent
reply
2 points

Throwing UTC everywhere doesn’t solve comparisons around leap seconds. I’m sure they’re other issues with this method, but this is kinda the point of “just use a library”. Then it’s someone else’s problem.

permalink
report
parent
reply
1 point

Unix is the easiest format I’ve used. It’s easy to parse, it’s consistent, there’s not usually competing unix like formats, it converts perfectly to other time formats, most file explorers can immediately sort it correctly, and it’s clearly the date from which the universe spawned into existence.

permalink
report
parent
reply
2 points

I’m a .NET dev, I don’t have a concept of “just use a library.” Everything is a library. I don’t mean “using int for datetimes is ok as long as you label it utc,” I just mean “don’t deal with time zones.”

permalink
report
parent
reply
25 points

What if I told you that weekend days are locale dependent?!

Time and date is the black hole where optimistic programmers go to die. Nothing is simply with localisation and if you think it is, you mustn’t have worked enough with it.

Source: Run a system that schedules millions of interactions across the world and deeply depend on this. The amount of code to manage and/or call out to external services to give us information about time zones, summer time, locale specific settings, day names, calendar systems, week numbers etc etc.

permalink
report
parent
reply
27 points

You forgot weekend = dayOfWeek.name[0] == ‘S’;

permalink
report
reply
21 points

Can confirm this works completely as expected when the user’s system is set to lang=ES.

permalink
report
parent
reply
1 point

true but that’s a precondition to some of the other examples as well

permalink
report
parent
reply
12 points
*

Simple save the users language setting in a variable, change it to english, check if the first letter is “s” and then change the language back.

permalink
report
parent
reply
2 points

Genius.

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 7.1K

    Monthly active users

  • 952

    Posts

  • 36K

    Comments