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.
Similar issue, we are in Japan which is GMT+9. Our working hour also start from 9am so a lot of time zone issue get missed because we are always running the test after the period with possible issues.
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.
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.
I think the person you’re replying to was suggesting “if you saw January was indexed ‘1’ would you think to check if December was ‘0’?” Which is a fair question. Presumably the person saw Monday = 1 and assumed it went up to Sunday = 7. Days also absolutely have a natural numerical representation. The first, second, third, etc. day of the week being 1, 2, 3, etc. makes perfect sense.
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.
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.
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.
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
As an American, I have never understood why we start with Sunday.
I'm not even particularly religious, and it just seems like Sunday should be the last day of the week. Plus, on calendars, it puts your weekend days together. WTF.
Sunday is the frontend, Saturday is the backend. The week exists between the ends. Just like a line segment: It has two ends, one on each side of the line.
We count it that way because the Jewish calendar placed the Sabbath as the seventh day, because that's the day God rested because creation was done and there was nothing left to add. Thus, the last day of the week became their day of rest and fellowship with God. And then Jesus was crucified on the day before the Sabbath, and rose again on (during) the day after the Sabbath, which was subsequently referred to as the Lord's day (officially formalised by Constantine, though in use before then). Thus, the first day of the week became the Christian day of rest and fellowship with God (while the Jewish day was still recognised and followed by early Christians, because most early Christians were devout Jews that believed in Jesus as the Messiah, the fulfillment of prophecy). And eventually, Rome began to observe this same pattern, because Rome had a decent Jewish population and was growing more and more Christian, and people weren't willing to work on either the first day or the Sabbath; their 8-day week wasn't working as well as the 7-day week, since it turns out that clamping the values to holiness makes the equations divine.
And ever since, we have classified this pair of "last day of one week, and first day of the next week" as the "weekend". It's not the week's rear end, and never was; the intent was that the "weekend" is the two days that sit at either end of the week, because weeks are incremental.
[This is also why we distinguish the "work week" from the "weekend", since the "work week" is the non-rest portion of the week that begins on Monday and ends on Friday.]
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.
In Portuguese, Monday is "segunda-feira", literally meaning 2nd fair, and it goes like that until "sexta-feira" (6th fair), then "sábado" and then "domingo".
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
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.
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 😂
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.
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.
All jokes aside, this kind of problem is the best example I've seen used to explain why writing testable code is important. Being able to run a unit test that feeds in an arbitrary Tuesday timestamp into your code and see it fail is incredibly useful.
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 the funny thing is all the Christian, Western nations used do the exact same and only moved away from it as they got less religious, so I think three assumption that it's a non-religious thing to do is wrong.
The old testament, specifically Genisis is not solely a Christian text. I know the days of the week were not derived from a Christian strain of religion. I was responding directly to the commentor who referred to the US as a religious country and didn't understand why the week started on the day of rest, which is the Sabbath according to the bible which is Saturday not Sunday, and I gave the first verse of the bible to indicate why they were wrong in their assumption.
This isn’t just a US thing. A bunch of foreign languages name their days with numbers in them and Sunday is the first day, though the notable exception is Chinese.
It's like if you point at a stick and ask where the two ends are and then get confused and angry when we point at two different sides. Like I don't hear you calling Tuesday the weekstart.
We use 60 seconds in a minute, 60 minutes in an hour, 24 hours in a day, 7 days a week. Worst of all, of course, is a month as a unit of time measurement when the value changes every other month, except when that's not consistent.
So until you're ready to move on from that ridiculous system, maybe hold your judgment on a country having a different "first day of the week" than yours.
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
853
u/Alacritous13 12d 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.
249
u/y0shii3 12d ago
This is why crontab allows both 0 and 7 to indicate Sunday
227
u/akazakou 12d ago
Do not tell him there are timezones that differ by half an hour.
125
u/Countach3000 12d 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.
1.1k
u/RedAndBlack1832 12d ago
Read the documentation moment
117
u/Jock-Tamson 12d 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.
230
u/FAMICOMASTER 12d ago
1 second of reading for 7 weeks of debugging
31
u/Active_Name5021 12d ago
What PL is this?
56
u/Azilen 12d ago
But this isn't an exclusive american thing.
23
u/Stormdancer 12d ago
As an American, I have never understood why we start with Sunday.
I'm not even particularly religious, and it just seems like Sunday should be the last day of the week. Plus, on calendars, it puts your weekend days together. WTF.
22
u/GrinningPariah 12d 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.
275
u/CeruleanSovereign 12d ago
Wtf why do Americans not even do days of the week in the right order?
17
u/IMightBeErnest 12d 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.
12
u/ANixosUser 12d ago
Tsoding 🅱️ased
6
u/wooops 12d 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
6
u/cjbanning 12d 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.
6
u/Pezmotion 11d ago
All jokes aside, this kind of problem is the best example I've seen used to explain why writing testable code is important. Being able to run a unit test that feeds in an arbitrary Tuesday timestamp into your code and see it fail is incredibly useful.
27
u/iain_1986 12d ago edited 10d 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?
Edit - Jesus Christ the seriousness with which this nonsense comment was taken in a joke sub 🤷♂️
4
u/ChiaraStellata 12d ago
And on the 7th day God rested, because he couldn't do any work during the unplanned downtime.
13
u/redsoxsuc4 12d ago
My guy seriously forgot to say “no mistakes on a sunday"
16
u/jolharg 11d ago
Monday is always the beginning.
Americans are not based.
Tsoding is based.
15
u/bobyhey123 12d ago
noob
5
u/mikegalos 12d ago
Welcome to understanding writing code commercially and not just to show off for your friends.
5
u/seedless0 12d ago
Sure. Blame it on someone else for your own lack of RTFM.
6
u/trollol1365 12d ago
the misuse of cyrillic is making me irrationally upset
2
u/qqqrrrs_ 12d ago
God started working in Sunday or something idk
2
u/anoldoldman 12d ago
And you caught this with a unit test... Right?
2
u/kaplotnikov 12d ago
it is also not reproduced on monday.
2
u/UsAndRufus 11d ago
Skill issue.
2
u/ItsClikcer 11d ago
And this is why you write unit tests to cover your boundary conditions
2
u/conundorum 11d ago
So... is he saying that he can't understand the concept of zero-based indexing unless weeks start on Saturday?
3
u/-Ambriae- 12d ago
Tsoding mentioned lesgoo
Also, America explain!!! I am confusion!!
2
u/OmegaTheta 12d ago
We use 60 seconds in a minute, 60 minutes in an hour, 24 hours in a day, 7 days a week. Worst of all, of course, is a month as a unit of time measurement when the value changes every other month, except when that's not consistent.
So until you're ready to move on from that ridiculous system, maybe hold your judgment on a country having a different "first day of the week" than yours.
1
u/Gnonthgol 12d ago
I once had a bug that was only reproducible in the last two weeks of the month or so.
1
u/GlitteringAttitude60 12d ago
It took us two years to notice that our test suite failed on Sundays :D
1
u/lostinthemines 12d ago
If your array was only one index too large, you would be fine
1
u/cubenz 12d ago
On Sundays and when you were testing I hope.
1
u/dingwinger1225 12d ago
1
u/FoxedDev 12d ago
Reminds me of the Date() API in JS
1
u/Tsc_Tsc_Tsc 12d ago
a-mr a-sozing, another banger.
1
u/Clouds-xD 12d ago
Didn't they call it the "weekend"?
1
u/winter-ocean 12d ago
I feel like there's an r/stunfisk joke in here somewhere
1
u/NoEngrish 12d ago
god wills it, not our fault
1
u/MaleficentMode4222 11d ago
So they start the week in the middle of the weekend?... Yeah sounds American.
1
u/Pouek_ 11d ago
I never thought I'll see a Mr Zozin here
1
u/No_Welder7908 11d ago
Arrays should always start at 1, too.
1
u/Loeris_loca 11d ago
Unexpected .jai mention
1
u/Zdrobot 11d ago
jai-linux new_event.jai..is it in that language no one has access to except for the people its developer has blessed for whatever reason?1
u/Ezekeal 11d ago
Do other countries not use an equivalent to the word weekend? Or do they use it incorrectly?
1
u/Brisngr368 11d ago
As always, Rtfm
1
u/Chr155topher 11d ago
They even start their floors at 0 they got our asses damn
1
u/palomdude 12d ago
We are very happy
1
u/nebotron 12d ago
Day of rest enforced by OBOE
1
u/Accidentallygolden 12d ago
Can you eli5?
1
u/White_C4 12d 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.
1
u/Hatedpriest 12d ago
Sun, Moon, Tyr, Odin, Thor, Freya, Saturnalia
Moon, Tyr, Odin, Thor, Freya, Saturnalia, Sun
I like keeping the sun and moon together.
0
u/tracernz 12d ago
What has this to do with Americans? This predates the existence of the US by a few thousand years. Old mate is just trolling.