lunes, 9 de noviembre de 2009

man date: %C: century; like %Y, except omit last two digits (e.g., 20)?

Oh, really? The only problem that I find in that statement is that it would be correct on the very last year of a century. I mean We are in 2009 and our century is the 21st, right?
Well, let's see what date says about our century:

$ date +%C

Lovely! What about in 1999?

$ date -d 19990303 +%C

So in 1999 being the 19th century, the closest thing I was to using a computer was an abacus (considering I was a windows user at the time we can agree I was actually using something next to an abacus).

And what about the last year of the 20th century?

$ date -d 20000303 +%C

Only then the definition provided by 'man date' does match the actual century for a certain year. And before people start complaining about 2000 being the first year of the 21st century instead of the last of the 20th century:
The year 0 doesn't exist in our calendar. Remember the gregorian calendar is roman based and romans didn't know the concept of 0, therefore no year 0. Theoretically speaking, from Dec 31st 1 BC, you'd have jumped into
Jan 1st 1 AD. If the first year of the first century is 1 AD and the last is 100, the first year of the second century is 101, the first year of the 20th century would be 1901 and the last would be 2000 and the first of the 21st century would be 2001 and so on. I used to discuss about this very same point with my Music History professor at the Conservatory in Maracaibo and we'd get into all kinds of philosophical questions about when it was 0, the limit between year
1 BC, 1 AD and so on and we'd never get to a point. My best wishes for my dear professor Osvaldo Nolé, by the way.

More info:

5 comentarios:

  1. You must have missed the part of the date man page that said that the century was 0-based not 1-based. Hence when it returns 20, it is really 21.

    Hehe, just kidding! (:

  2. I've heard that "no zero" argument before. The thing is, it doesn't make any sense.

    The Gregorian calendar was adopted in 1582 (by Pope Gregory XIII--hence the name), which means there very much WAS a concept of 0 when the calendar was created.

    You could argue the "no zero" thing about the Julian calendar, I suppose, but that would be pretty academic, as we don't use it.

    Note that I'm not expressing an opinion about what dates comprise which century. Just that the reasoning you're parroting is ridiculous.

  3. @openid: The thing is that the gregorian calendar is basically an _adjustment_ on the julian calendar to create the 400-year cycle for leap years. Had they decided to use year 0 at that time, they would have had to go a whole year back (in numbering) instead of skipping 10 days in their calendar at the time.

    The fact remains: There's no year 0 in the gregorian calendar. It doesn't matter if we like the idea or not or if we consider it silly or not. It's just what it is.

  4. I don't understand your problem. This is working exactly as specified. What you're trying to do is map the number of centuries since 1 B.C. with the 4 digit year. +%C is not doing this. What +%C is doing is giving you the the first two digits of the four digit year, which are called the century marker.

    Think of it this way: In 1999, we are in millenium 1, century 9, decade 9 and yaer 9, or you can say "century 19, decade 9 year 9.

    This was also done on blank checks. Remember filling out the last two digits of the year on your checks? You would have something like:

    Date: ___________ 19__

    Isn't that 19 the cuntury marker? It's not saying we're in the 19th century. It's saying that "we've filled out century 19 for you, you fill out the decade and year."

    That's all this is doing. If you want to count the number of centuries from 1 B.C., then add a one to that number, as this date formaat is not doing what you want think it is.

  5. @Aaron: That explanation could make it... but I think it should be clarified on the man page.

    Also, what I think I _should_ get is not fixed by just adding one to the output of +%C, cause that would _break_ the last year of the century.

    In a few words: The man page should be a little more verbose about what +%C would do (IMnsHO).