News for hackers. Stuff that matters.
Re:Again on 0-based vs. 1-based indexing by IlliOnato on Wednesday January 20, 2021 @01:46AM (#25843250)
While I don't have a strong preference in this "war", I can think of an interesting argument for 1-based.

Our time counting is 1-based. There is no zeroth second, zeroth minute, hour, day, month, year, or century. This actually makes it slightly harder in 0-based languages to work with time and dates.

Also, it might be an indication that 1-based system is somewhat more intuitive to non-programmers.

Re:Again on 0-based vs. 1-based indexing by hmry on Wednesday January 20, 2021 @04:03AM (#25844189)
> There is no zeroth second, zeroth minute, hour

My clocks all start at 00:00:00 every day, and that seems entirely logical to me. It's also how all programming languages that I've worked with represent time.

Re:Again on 0-based vs. 1-based indexing by IlliOnato on Wednesday January 20, 2021 @07:03PM (#25853576)
But 00:00:00 does not represent the first second of your day. It represents a _point_in time, which has no duration.

The first second of your day is an interval between the moment your clock shows 00:00:00 and the moment it shows 00:00:01.

If 00:00:00 is the fist second, why it's not the first minute and not the first hour? Is the fist second is the same as the first minute and the first second?

Re:Again on 0-based vs. 1-based indexing by wraptile on Wednesday January 20, 2021 @03:56AM (#25844142)
Our counting is 0-based as well - usually when you start by saying "one" it is implied that 1 second has elapsed. So while we don't pronounce zero we still count starting from it.
Re:Again on 0-based vs. 1-based indexing by adwn on Wednesday January 20, 2021 @04:49AM (#25844482)
Also when counting down: "3, 2, 1, go!", where "go" means 0 seconds left. Therefore, it's 0-based as well.
Re:Again on 0-based vs. 1-based indexing by IlliOnato on Wednesday January 20, 2021 @07:05PM (#25853595)
The first second is one which passes between 0 and 1. Counting time is 1-based. Points in time (which have no duration) are 0-based...
Re:Again on 0-based vs. 1-based indexing by flukus on Wednesday January 20, 2021 @01:59AM (#25843328)
> There is no zeroth second, zeroth minute, hour, day, month, year, or century.

No there isn't, but we still use 0 to denote the first minute of an hour, just as we use 0 to denote the first element of an array.

Re:Again on 0-based vs. 1-based indexing by OJFord on Wednesday January 20, 2021 @04:09AM (#25844229)
Yes, this isn't usually an argument I care for, I happily use zero-based and occasionally having to pause to remember to get it right in SQL is a minor annoyance and that's that.

But then recently I was doing some 'munging' to get some data structured correctly to display in a chart over months, with a variable start month that depended on the data. Well, let's just say that involved a fair amount of +/- 1 ing, and is hopefully the last time I think 'hm, it'd actually be quite nice if you could choose which to use on access' (or per function?).

Re:Again on 0-based vs. 1-based indexing by IncRnd on Wednesday January 20, 2021 @04:07AM (#25844218)
There absolutely is a zeroth second! It is the 60th second of the prior minute. This is actually the exact reason why midnight is 12 AM not 12 PM, and noon 12 PM not 12 AM.

If there weren't a zeroth second, minute, hour, day, month, year, or century when was 12:00 AM of Jan 1, 2000?

This is why a zero _offset_ is the initial _value_ for many implementations.

Re:Again on 0-based vs. 1-based indexing by IlliOnato on Wednesday January 20, 2021 @06:42PM (#25853403)
... And I (a non-native English speaker living in the US) always have trouble remembering what 12 AM and 12 PM means, even after all these years I have to look it up every time, and sometimes it drives me nuts.

(For a moment I hoped your explanation would at least serve as a heuristics... but alas, it does not make sense to me. Well, at least at the moment I remember the notation).

Regardless of it, "12:00 AM of Jan 1, 2000" is not a particular second. It's a point in time, it has no duration.

It does not belong to any particular calendar hour or day or year, it's a _boundary_ between two.

Of course it belongs to XX century since XXI century starts at 12:00 AM of Jan 1, 2001.

The first second of Jan 1 lasts from 12:00::00 AM to 12:00:01 AM.

First minute of that day lasts from 12:00 AM to 12:01 AM. Etc.

At least this is how I parse it.

Re:Again on 0-based vs. 1-based indexing by vbarrielle on Wednesday January 20, 2021 @04:05AM (#25844208)
> Our time counting is 1-based.

Not in every part in the world. Here in France, we use 24h time, and midnight is 00:00. Very convenient.

Re:Again on 0-based vs. 1-based indexing by OJFord on Wednesday January 20, 2021 @04:16AM (#25844279)
I'm not French, but your comment just made me 'realise' that people who use 12h have the largest numbers when we on 24h have the smallest, almost like the 'start' is one o'clock. Weird.

Same :00 start happens with minutes on 12h though of course.

I think GP didn't mean to talk about time, has a point regarding months as I replied elsewhere. We represent the months numerically as 1-12, and I have recently found that annoying to work with.

Re:Again on 0-based vs. 1-based indexing by linknoid on Wednesday January 20, 2021 @08:49AM (#25846379)
12:00 should actually be 0:00 on the 12 hour clock, it belongs to the next 12 hour period. 11:59 PM is yesterday, 12:00 AM is one minute later, and falls on today. Same with noon, 12:00 PM comes one minute after 11:59 AM. When I see 12:00, I automatically convert that to 0:00, otherwise AM/PM doesn't make sense.
Re:Again on 0-based vs. 1-based indexing by vbarrielle on Wednesday January 20, 2021 @04:22AM (#25844327)
Indeed, months are 1 based, but it's never been a problem to eg compute which month it will be, say 9 months later: just sum and subtract 12, no need for a real modulo computation. It's probable I've never found it annoying because I don't need to perform this computation with more than 12 months.
Re:Again on 0-based vs. 1-based indexing by IlliOnato on Wednesday January 20, 2021 @07:07PM (#25853618)
Yeah, this is most familiar to me too. Still, I'd argue it's 1-based. 00:00 is a point in time, but the first second is between 00:00:00 and 00:00:01, and it's "00:00:01" when it has elapsed.

No?