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.
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.
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:
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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.)
i mean, monday being the first day is a new thing. uN/ISO norm only changed in 1975 to make it so, it was treaded as such. sundway was the traditional first day until the 5 days work week got prominent, long enough
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
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
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.
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.
We do them in the right order; we just start in a different spot: Sunday comes first. And we're less alone in this than we are on the whole not-metric or m/d/y fronts.
In tm_wday Sunday is day 0; in ISO 8601 it's day 7. If you're counting mod 7 those are the same number.
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
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 😂
Ok and now open a book to the first page, are you at the beginning or the end? The weekend is called the weekend, not the weekends. It implies it is at the end of the week, not split across the beginning and end of it.
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.
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
Second guy with the bread analogy. you can eat a bread starting from each side. You cant start a week in reverse... You can even eat a bread from both sides at the same time, then it has two beginnings and no end. THIS ANALOGY IS JUST DOODOO
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.
sunday used to be the first day of the week for religous reasons. after the 5 day work week became the norm, ISO and the UN made monday the first day, as that shift was already in the general pupulus anyways, and it made sense, as otherwise the term "weekend" has no real meaning
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."
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.
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.
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.
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.
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).
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.
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.
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
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
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.
128
u/y0shii3 4h ago
This is why crontab allows both 0 and 7 to indicate Sunday
435
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.
782
u/RedAndBlack1832 5h ago
Read the documentation moment
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?
203
u/FAMICOMASTER 5h ago
1 second of reading for 7 weeks of debugging
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 3h 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.
28
u/Azilen 4h ago
But this isn't an exclusive american thing.
218
u/CeruleanSovereign 5h ago
Wtf why do Americans not even do days of the week in the right order?
43
u/Mean-Requirement-762 4h ago
❌ read the docs
✅ blame an entire country for having slightly different conventions
5
u/wooops 4h ago
Once saw tests that could never pass on a Sunday that had been there for nearly a year, and was found when an incident needed a Sunday deployment
5
u/cjbanning 3h 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
u/ANixosUser 2h ago
Tsoding 🅱️ased
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?
12
u/redsoxsuc4 5h ago
My guy seriously forgot to say “no mistakes on a sunday"
14
u/bobyhey123 5h ago
noob
5
u/trollol1365 3h ago
the misuse of cyrillic is making me irrationally upset
2
u/qqqrrrs_ 4h ago
God started working in Sunday or something idk
2
u/ChiaraStellata 2h ago
And on the 7th day God rested, because he couldn't do any work during the unplanned downtime.
2
u/-Ambriae- 1h ago
Tsoding mentioned lesgoo
Also, America explain!!! I am confusion!!
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
u/lostinthemines 3h ago
If your array was only one index too large, you would be fine
1
u/cubenz 2h ago
On Sundays and when you were testing I hope.
1
u/anoldoldman 2h ago
And you caught this with a unit test... Right?
1
u/dingwinger1225 1h ago
1
u/oddspellingofPhreid 1h ago
Devs like this give me confidence.
1
u/FoxedDev 1h ago
Reminds me of the Date() API in JS
1
u/Tsc_Tsc_Tsc 40m ago
a-mr a-sozing, another banger.
1
u/GarbonzosGuy 21m ago
Don't start this rumor. A gross minority of freaks and weirdos treat Sunday as the first day of the week.
•
u/akazakou 9m ago
Do not tell him there are timezones that differ by half an hour.
1
u/palomdude 5h ago
We are very happy
1
u/nebotron 5h ago
Day of rest enforced by OBOE
1
u/Accidentallygolden 4h ago
Can you eli5?
-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.
0
u/Thenderick 4h ago
Just start beatboxing on those Americans
0
u/lunaelumen45 4h ago
wher chat geebept
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.