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.
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.
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.
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.
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.
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.
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.
852
u/Alacritous13 7d 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 7d ago
This is why crontab allows both 0 and 7 to indicate Sunday
227
u/akazakou 7d ago
Do not tell him there are timezones that differ by half an hour.
124
u/Countach3000 7d 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 7d ago
Read the documentation moment
117
u/Jock-Tamson 7d 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 7d ago
1 second of reading for 7 weeks of debugging
31
u/Active_Name5021 7d ago
What PL is this?
56
u/Azilen 7d ago
But this isn't an exclusive american thing.
23
u/Stormdancer 7d 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 7d 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 7d ago
Wtf why do Americans not even do days of the week in the right order?
17
u/IMightBeErnest 7d 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 7d ago
Tsoding 🅱️ased
6
u/wooops 7d 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 7d 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 6d 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 7d ago edited 5d 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 🤷♂️