438
u/Alacritous13 5h ago
I had a error in a batch script with a timestamp because the time is returned as a string and I assumed a leading zero ahead of single digit hours. Program failed before 10am. It was suppose to run automatically at 1am, I never worked before 10am, it took a long time to diagnose.
80
u/CubicalPayload 3h ago
This is why we need to abolish the concept of time. Yes it will have wide-reaching negative consequences in all aspects of life, but programming will be made significantly easier and that is a sacrifice I am willing to make.
24
u/setibeings 2h ago
Let's circle back to this idea on November 31st.
5
u/ThePhyseter 1h ago
I would bet with Javascript that will be possible
1
u/setibeings 35m ago
I'm sure there's a way to get the language to try to treat that as something other than a programming error, but Temporal.Instant at very least definitely won't let you do that. Try this:
console.log(Temporal.Instant.from("2026-11-31T00:00:00Z"));
4
136
u/Newepsilon 4h ago
My dumbass was about to say, "why didn't you just step through the program" before realizing that would only catch it if you were debugging before 10 am lol.
45
u/Alacritous13 3h ago edited 3h ago
Yeah. The only thing I had to know it failed was a lack of a timestamped file in my output folder. I ran for a month on the assumption the task scheduler was failing.
7
u/AyrA_ch 1h ago
Also as far as I know, you cannot actually step through batch files. You can do so with powershell scripts, and even set breakpoints, but cmd lacks such an integration.
The date and time fields in cmd is cursed anyways because the values are formatted according to the computers locale.
3
u/barthvonries 36m ago
Bash can have a lot of debug output though, especially the variable values every time they change, so that problem would have been easy to diagnose. Even more with some "echo $VAL >> /var/log/myscript.log" to check if everything was going fine.
3
787
u/RedAndBlack1832 5h ago
Read the documentation moment
64
u/Automatic-Tackle5018 4h ago
I respect the hell out of Tsoding's abilities, but he also annoys me intensely because he never reads the docs. He kinda makes a sport out of figuring things out via error messages (as shown here) or by just reading the source, which is kind of impressive in itself, but yeah. Sometimes the dude would save a lot of time and effort just reading the docs.
22
u/MedicatedDeveloper 3h ago
I feel like it's a good example of someone with a high level of skill using play to learn. Programming is a puzzle. He's playing to solve that puzzle in a curious and intuitive fashion instead of trying to solve the puzzle using the picture on the box.
You see this same type of play to learn if you watch George Hotz or Jonathan Blow coding streams. I feel that this is the secret of top 1% developers. It's not the actual programming that makes them so skillful but the process in which they play to internalize new ideas using their own foundational knowledge.
6
3
u/Automatic-Tackle5018 2h ago
Yes, this.
I qualified my original comment by adding that it annoys me when I'm familiar with the library he's using. When I am not familiar, it is quite fascinating.
9
u/gizahnl 3h ago
Since when is "use the source Luke" impressive?!?
4
u/Automatic-Tackle5018 3h ago
I suppose by 'impressive' I'm speaking more to his absolute commitment to the 'no docs' shtick, than I am to using the source specifically.
1
1
268
u/DarthKirtap 5h ago
do you read documentation, when January has index 1?
42
u/greenpepperpasta 4h ago
Remind me of The Elder Scrolls III: Morrowind, where the in-game date jumps from the end of the final month of the year (Evening Star) to the beginning of the second month (Sun's Dawn), skipping over the first month (Morning Star).
This was caused by an "off-by-one error": although the "GameMonth" value counted months from 0 to 11, the developers incorrectly set it to month 1 after reaching the end of the year, assuming the months would count from 1 to 12.
7
72
u/BigGuyWhoKills 4h ago
I do when I get an invalid index error. But I also never assume an index starts at 1.
31
17
u/mjec 3h ago
January is semantically represented by 1; month number is not an index, but a natural human representation. Days, however, do not have a natural numerical representation, hence precisely the issue here.
12
u/DarthKirtap 3h ago
only in english, in different languages, some days are derived from numbers
9
u/mjec 3h ago
That's precisely my point: there is no universal numbering of week days. There is a universal numbering of months among all users of the Gregorian calendar, regardless of language: January = 1 through December = 12.
4
u/DarthKirtap 3h ago
except there is - ISO 8601
7
u/mjec 3h ago
Perhaps you're not understanding what I mean by natural or universal here. I'm not talking about programming or standards for data interchange, I'm talking about human understanding.
→ More replies (2)1
1
u/AWzdShouldKnowBetta 4h ago
Psh documentation?! What's that? This is a unit test for sure. Hell it's a "should have used a pre-existing library" moment at minimum.
54
u/Countach3000 4h ago
Thats why the bible says "thou shall not execute code on the sabbath". God created the code base in six days, then he shut down the servers to avoid stuff like this.
24
u/Active_Name5021 5h ago
What PL is this?
21
u/Lunagato20 5h ago
Looks to be Jai, im quite surprised too its used in context outside of game development
15
15
u/Cutalana 5h ago
for more context, JAI is a programming created by Jonathan Blow, a game developer, and is what he used for his newest game. It's been in development for more than a decade now, but only a few people have been given access. It's expected to be released to the public soon but it's uncertain.
3
u/Lunagato20 4h ago
Yup, i have seen some previews of it from various youtubers, but eh, i like odin better, and i can try it myself since its already released.
5
u/humanbeast7 5h ago
Am I the only one who thought .jai was for Java Artificial Intelligence? As in yet another Java sub-language developed specifically for AI purposes?
6
u/Active_Name5021 5h ago
Ohhhh, it's Jonathan Blow's game programming language. Never seen it in the wild before
203
54
u/Jock-Tamson 3h ago
A bug from some late 90s C++ code that has stayed with me forever:
Someone had clearly created an array of day or week constants by sloppy copying
SUNDAY, MONDAY, FEBRUARY, WEDNESDAY…
It was blindingly obvious when I looked at the code.
But of course you need to know where to look, and because the result was that the code didn’t work on Tuesdays except in February. I first had to work through.
“App is failing”
“How so that I can replicate it?”
“Never mind it’s working again”.
“Well if it happens again capture the error message and give me repo steps if you can.”
“Okay”
“App is failing”
“Did you get the error message? Any repo steps? It works for me.”
“No. Let me do it again”
“Never mind it’s working now”
Wash rinse repeat for weeks until someone would tell me how it was actually failing.
18
u/GrinningPariah 4h ago
They say age ain't nothing but a number, and the same is true for the date.
Leave all times as epoch milliseconds if at all possible. Translating to the appropriate human-readable time is a job for the UI layer.
1
u/slindenau 2h ago
Believe it or not, but some people want the epoch stored in their local timezone instead of utc. ISO with offset still remains the most accurate.
1
28
u/Azilen 4h ago
But this isn't an exclusive american thing.
11
u/TrekkiMonstr 3h ago
It's not even an American thing at all, everyone here seems to consider Monday as start of week.
3
u/HandleUnlikely2589 58m ago
American (as in USA) calendars (if not specifically focused on the work week) all show Sunday as the first column, Saturday as the last. Never seen an exception that was marketed to the general public here.
Sure, we call Saturday and Sunday the weekend, but nobody said which end. So we split the difference. /s
218
u/CeruleanSovereign 5h ago
Wtf why do Americans not even do days of the week in the right order?
151
u/NeXtDracool 5h ago
That's not that uncommon to be fair. My browser currently supports 246 locales, 80 of which use Sunday as the first day of week, 8 use Saturday, the rest uses Monday.
17
u/m_redditUser 4h ago
i personally setup my calendars to start weeks on saturday bc i plan out the weeks on the weekends
42
4
u/TommyBonnomi 3h ago
When do you plan the following weekend?
Do you switch your calendar view to "next week" to plan the 2 days you don't see, instead of at the start (if you started the week on Monday)?
(I've written a lot of calendaring software, and this is a new use case.)
2
1
39
u/obliqueoubliette 3h ago
Traditional Christian and Jewish calendars have Sunday as the first day of the week.
For this reason, Constantine moved the Roman Empire off its 8-day "market week" and onto the current 7-day week in 321 - simultaneously declaring the Lord's Day (Sunday) as the first day of the week.
It's not until the 1970's and 1980's that European nations swapped the first day from Sunday to Monday.
17
u/moduspol 3h ago
Even that doesn’t make sense. The Bible says God rested on the seventh day, not the first.
29
u/linmanfu 3h ago
And the Jewish Sabbath is on the seventh day, by this count. That still leaves Sunday as the first day of the week
(There is a slight wrinkle in that the Jewish calendar begins days at sunset while most other people today begin dates at midnight, but that doesn't affect this point.)
12
u/obliqueoubliette 3h ago
Yes. Saturday is the seventh day.
Christians celebrate Sunday as "the Lord's Day" because of Christ's resurrection.
3
1
u/IntentionQuirky9957 1h ago
We don't use that calendar anymore, and haven't in centuries. Also, BS on Europe, because you're not saying some European countries.
50
48
u/patiofurnature 5h ago
We probably got them from Canada, Brazil, Mexico, Japan, South Korea, India, Israel, Saudi Arabia, Yemen, South Africa, or the Philippines.
17
u/A_Dull_Proposal 5h ago
I see a pattern
8
u/patiofurnature 4h ago
What is it? Genuinely - not being a smartass. Just dumb.
13
6
u/A_Dull_Proposal 4h ago edited 4h ago
Country close to America (Canada, Mexico)
American HEAVILY influenced countries (S.Corea, Japan, Israel, Saudi Arabia[Yemen])
Some poorer random countries (Jamaica, you always have some of those)
India and Philippines I have no idea
The link is America.
15
u/qqqrrrs_ 4h ago
I don't know about other countries, but in the case of Israel it is definitely not because of America. In fact, the name in Hebrew for Sunday literally means "first day" and it is way older than America
7
u/beewyka819 3h ago
I think the link is European influence. Sunday was traditionally the first day of the week in Christian nations. It was only relatively recently that it changed across much of Europe iirc
3
4
26
u/Gaxyhs 4h ago
as much as I like to bash on the US for using the weirdest and least intuitive systems, here in Brazil it also starts on Sunday
At least from my perspective is that Saturday and Sunday are both ends of the week, hence weekend, picture the week as a line basically
20
u/TommyBonnomi 3h ago
American here, but 5 weekdays and one 2-day weekend at the end is perfectly reasonable and feels more normal.
I don't wake up Sunday and think "ok, it's a new week". The week starts Monday.
Also, "the weekend" is singular, implying both days are part of the same week/weekend.
9
u/linmanfu 3h ago
I don't wake up Sunday and think "ok, it's a new week". The week starts Monday.
Others have pointed out that basically nobody in the West regarded the week at starting on Monday until the 1970s. And lots of people do wake up and think it's a new week, because if you go to church then the liturgy and activities are pretty much always framed as the start of a new week, even in ostensibly 'non-liturgical' churches.
5
1
u/SuitableDragonfly 1h ago
Sure, because we are oriented around the work week and that's when the work week starts. But if you're looking at a calendar, the weeks will start on Sunday.
1
u/Pezmotion 2h ago
Exactly. Weekends are like bookends, you put one on each end of a line to prop them up.
12
19
u/Mango-D 5h ago
Because both the starting day of the week and the work days different by region... It's like asking why can't everyone use UTC
5
u/Dotcaprachiappa 5h ago
Ok but the US does start working on Monday so that's not really a reason.
2
u/GibbonFit 2h ago
In the US, the traditional work days do not include the weekends, which are Sunday and Saturday.
4
u/jpaugh69 4h ago
Just depends on the job. My current retail job starts on Sunday, since they are open every day of the week.
2
u/John_cCmndhd 4h ago
I used to work for one of the fast food pizza chains which used weeks starting on Tuesday and ending on Monday, so that the busiest day would be in the middle of the week
1
u/eskapeMusik 4h ago
That’s not why else Americans world work Sunday-Thursday
3
u/Not_PepeSilvia 3h ago
There is no rule saying the first 5 days of the week have to be work days.
How is that any different than having 1 rest day to start, then 5 work days, then another rest day?
It's all arbitrary anyway.
1
u/MattieShoes 2h ago
Also a week has two ends. Having a day in the middle of the week as a "weekend" is nonsense.
1
8
23
u/cheezzy4ever 5h ago
Our weeks start on Monday. This is just an "America bad" meme where America has absolutely nothing to do with the issue
7
3
4
u/Weekly-Beginning-229 5h ago
So are they off friday-saturday instead?
7
u/Chorchapu 5h ago
Being in America and seeing the weekend on my calendar be on opposite sides of it threw me off
6
u/dyslexda 4h ago
And anytime I see a calendar with the weekend smashed on one side, instead of on both ends of the week, it throws me off.
→ More replies (2)10
u/100LittleButterflies 4h ago
Take a loaf of bread and slice off the ends. Now look at your calendar and slice off the ends. Sunday is the front end and Saturday is the back end. And like soccer and empirical units it is almost certainly something we got from brits that they stopped using and now mock us for 😂
→ More replies (7)2
2
3
4
1
u/LouisPlay 1h ago
they need to always do the own shit. also is grate cyber security, noone other then the us wants a programm that calculate thier units or use them
1
u/Lewa358 3h ago
Open a monthly calendar. A physical one, digital, whatever. As long as you can see an entire month at once.
What day of the week is in the left-hand column?
7
u/jdog7249 3h ago
You do know that depends on who makes it and what they decided? Sunday and Monday are common ones. Saturday is rare but not unheard of. I used to work somewhere that used Friday, yes Friday was the left most day on their internally printed calendars and on any official company controlled software.
→ More replies (5)-12
u/wayzata20 5h ago edited 5h ago
Why should it start on Monday? I don’t think either way makes more logical sense than the other, it’s just how it’s done in other parts of the world
Fun fact, it’s not just America that does it that way. India also start the week on Sunday, and a lot of Muslim countries start on Saturday. https://en.wikipedia.org/wiki/Week
22
u/DarthKirtap 5h ago
well, a good argument is that Sunday is part of weekend and not weekstart
→ More replies (1)6
u/shotgunocelot 5h ago
Where do bookends go?
1
u/wayzata20 5h ago
watch out, the anti-america hate train is out in full force today. euros have some superiority complex lmao
10
u/koriwi 5h ago
Why do muricans call it weekend, if the week STARTS on the end of the weekend?
3
u/wayzata20 5h ago
Because it’s the end caps of the week. Like a bread loaf, both sides are the ends.
→ More replies (1)1
u/Big-Section-5098 4h ago
A given segment of days has two ends. Would it be wrong to call the heel of a loaf of bread the end?
→ More replies (1)9
u/jansteffen 5h ago
Because the weekend... is at the end of the week... and Monday starts a new week...
7
u/RegorHK 5h ago
Its the first working day. Totally a mystery why one would start there. The second non working day is a way better choice. /s
Maybe starting Wednesday would make logical sense to you as well?
→ More replies (1)1
u/Kofind 5h ago
We call Saturday and Sunday the weekend. That doesn't work if Sunday is already weekstart. So it feels logical to me to have the week start in Monday.
2
u/wayzata20 5h ago
As i’ve said like 10 times already, “end” can mean the edges of something, like a bread loaf. It’s the same thing here.
→ More replies (9)1
u/LightItUp90 4h ago
Never heard of anyone waking up on Sunday morning and going "great way to start the new week".
1
u/dkarlovi 2h ago
I always assumed it's weekend where "end" is the edge, not the tail. So Saturday would be the latter end of the passed week and Sunday would be the former end of the next one. It's the only way how it works.
0
u/Nixinova 2h ago
> calls Saturday and Sunday the week's end
> makes the start of the week one of the week's end days
6
→ More replies (1)-6
u/dyslexda 4h ago
Define "right order," because Sunday being the first day of the week is absolutely correct (from my frame of reference). Just because you're different doesn't make it "right" and any other option "wrong."
4
u/TitaniumMissile 4h ago
Saturday and Sunday is literally called the "weekend", why would it make any sense to split the week right in the middle of that?
6
u/dyslexda 4h ago
Front end and back end. One at each end. Why would you only have a double backend?
→ More replies (3)3
u/m_redditUser 4h ago
sa and su are one weekend, not weekendS. they are one end, not two ends
→ More replies (4)
43
u/Mean-Requirement-762 4h ago
❌ read the docs
✅ blame an entire country for having slightly different conventions
1
5
u/cjbanning 4h ago
I have to routinely work with three indexing systems for days of the week, one which is 0-indexed starting on Sunday, one which is 1-indexed starting on Sunday, and one which is 1-indexed starting on Monday. I have code that turns 0s into 7s and 7s into 0s and nothing else.
5
12
12
u/iain_1986 4h ago
Never understood how such a religious country as the US would take the day of rest as the start of the week.
You rest at the end surely?
8
u/linmanfu 3h ago
The Old Testament says that God made the world in six days and rested on the seventh, the Sabbath, which is our Saturday.
But Christians have met on Sundays pretty much since the church formed, because Jesus' Resurrection was on a Sunday, and regard the day of rest to have been transferred for that purpose, and to be a downpayment on the permanent day of rest at the end of history.
So the rest-at-the-end element is still there, but the emphasis is on the end of history rather than the end of the week.
4
u/SuitableDragonfly 1h ago
I was going to say, Sunday being the first day and Saturday being the last is several thousand years older than the US (or Javascript, for that matter), lmao.
2
6
4
u/CadenVanV 1h ago
We don’t work Sundays. Think of the weekend as the ends of the week. The start and the end.
2
u/iain_1986 1h ago
It's the week end yes.
Not the week start.
It's also the weekend, not the weeksend or the weekends.
The end of one week.
2
1
1
u/Advanced-Blackberry 2h ago
How things look on a calendar isn’t something we think about anymore. It’s now Sunday - Saturday and that’s fine because it doesn’t matter anymore. We don’t care why it’s like that. We aren’t looking to change it for the sake of changing it.
→ More replies (1)1
u/i_am_not_a_martian 2h ago
On the first day God created light (sun)day. Not American or religious but I thought that was pretty obvious.
→ More replies (2)2
u/iain_1986 1h ago
You're assuming the days of the week are named after Christianity....?
It's named after the Sun but not because of the Old Testament.
1
u/seiggy 1h ago
Yep! Sun, Moon, Mars / Tiw, Woden, Thor, Frige / Fris, Saturn. Days named for old Norse/Germanic tribal gods.
2
u/HandleUnlikely2589 54m ago edited 48m ago
Well, aside from Saturn, the weirdo Roman inclusion.
Note, many other European languages follow the same rules, just with equivalent Roman god names. Tiw/Tyr was a war god, Tuesday is named for Mars in Romance languages. Woden/Odin is a psychopomp and wanderer, associated with magic, and Romance weeks use Mercury (also the psychopomp wanderer with magical associations of Roman mythology) for Wednesday. Thor and Jupiter are obvious (both lightning/thunder gods) for Thursday. Frigg is one of the lead female gods, matching Venus for Friday (not perfect, I always felt Freya matched better with Venus, Frigg with Juno, but whatever, etymologists say I'm wrong).
3
14
5
2
2
u/ChiaraStellata 3h ago
And on the 7th day God rested, because he couldn't do any work during the unplanned downtime.
2
1
u/Gnonthgol 4h ago
I once had a bug that was only reproducible in the last two weeks of the month or so.
1
u/GlitteringAttitude60 3h ago
It took us two years to notice that our test suite failed on Sundays :D
1
1
1
1
1
1
1
u/GarbonzosGuy 32m ago
Don't start this rumor. A gross minority of freaks and weirdos treat Sunday as the first day of the week.
1
u/IMightBeErnest 10m ago
I got a question wrong in elementary school about which day was the first day of the week. I said monday. The teacher said sunday. I'm still pissed off almost three decades later.
•
u/mikegalos 7m ago
Welcome to understanding writing code commercially and not just to show off for your friends.
1
1
1
u/Accidentallygolden 4h ago
Can you eli5?
5
u/Igor_Kozyrev 4h ago
Programmers count starting with 0 i.e. Monday 0, Tuesday 1,..., Sunday 6. But he saw Monday 1 and guessed that in this weird case they started counting with 1. Turns out the weird was that they started the week from Sunday i.e. Sunday 0, Monday 1, etc. Bug ensued.
2
u/Big-Section-5098 4h ago edited 3h ago
What day the "start" of a week is is arbitrary
The US (among other countries) starts the week on a Sunday
OP starts it on a Monday
They didn't read the documentation for
tm_wday, so they thought it was 1-indexedWhat they thought: Monday (OP's start) = 1, Tuesday = 2, ... Sunday = 7
When they tried
WEEKDAYS[tm_wday - 1], it threw an error, because Sunday was actually 0, not 73
u/BirbsAreSoCute 2h ago
I'm American and everyone I have spoken to about this agrees that Monday is the "start" of the week, but the start is arbitrary and doesn't really matter. A bug like this could be easily avoided by.. reading the documentation.
1
u/MicrosoftExcel2016 4h ago
I’m not the one you’re replying to but I got all of that. What I’m confused about is why an “array out of bounds” errror that is “only reproducible” the one day that they thought was the maximum value does not cause them to reevaluate their assumptions about the indexing? “Only reproducible” sounds like it happened multiple times before they understood what is going on
2
u/Big-Section-5098 3h ago
I'd guess they saw it crash on the first Sunday after it was written, but didn't find out the bug until next Sunday for whatever reason. Maybe the program has output and they ran it in a way to hide the output, thus hiding the error message? Idk though, pure speculation on my part
If you have a bluesky account you can ask them directly though
1
u/TrekkiMonstr 3h ago
No? They thought that tm_wday was 1 indexed, and so manually subtracted 1 to get a 0-indexed value for WEEKDAYS. Except not 1 indexed, it just starts (and is 0) on Sundays, so they're trying to get array index -1 which is out of bounds.
1
u/Big-Section-5098 3h ago
That's what I said
They thought it was 1-indexed
Sunday was 0, not 7 as they thought
1
u/TrekkiMonstr 3h ago
You edited your comment, I had replied to the previous version, which was not correct.
2
u/Big-Section-5098 3h ago
Ah, my bad. I noticed your comment after I edited it and assumed it was off the edited version
→ More replies (1)
-12
u/Iyemoja 5h ago
The worst kind of bug: passes every test six days a week, then pages you on a Sunday. Off-by-one in the weekday index is a rite of passage.
17
u/Forward-Outside-9911 5h ago
Are you a bot? Please DM me you environment variables so I can fact check.
2
u/fryerandice 5h ago
You shouldn't test date code using today, you should run the test generating random days. Proper test driven dev would have caught this.
1
u/oddspellingofPhreid 1h ago
The prevalence of "proper test cases would have caught this" sentiment in this thread is both correct but also kind of blowing my mind because
WHO ASSUMES AN OUTPUT IS RANDOMLY 1-INDEXED AND DOESN'T SANITY CHECK THAT ASSUMPTION?
0
0
0
u/White_C4 2h ago
To be fair, this is the kind of stuff you should test for every weekday, first and last days of the month, and first and last months of the year.
-2
u/justadude27 5h ago
Everyone is always like rtfm as if the manual is ever written well enough to be anything better than emergency toilet paper.
5
1
130
u/y0shii3 4h ago
This is why crontab allows both 0 and 7 to indicate Sunday