calendar in unix

how to get the calendar for the year 10000 like we get calendar for say year 2010.

$ cal 2010
 
                                2010
         Jan                    Feb                    Mar
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
                1  2       1  2  3  4  5  6       1  2  3  4  5  6
 3  4  5  6  7  8  9    7  8  9 10 11 12 13    7  8  9 10 11 12 13
10 11 12 13 14 15 16   14 15 16 17 18 19 20   14 15 16 17 18 19 20
17 18 19 20 21 22 23   21 22 23 24 25 26 27   21 22 23 24 25 26 27
24 25 26 27 28 29 30   28                     28 29 30 31
31
         Apr                    May                    Jun
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
             1  2  3                      1          1  2  3  4  5
 4  5  6  7  8  9 10    2  3  4  5  6  7  8    6  7  8  9 10 11 12
11 12 13 14 15 16 17    9 10 11 12 13 14 15   13 14 15 16 17 18 19
18 19 20 21 22 23 24   16 17 18 19 20 21 22   20 21 22 23 24 25 26
25 26 27 28 29 30      23 24 25 26 27 28 29   27 28 29 30
                       30 31
         Jul                    Aug                    Sep
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
             1  2  3    1  2  3  4  5  6  7             1  2  3  4
 4  5  6  7  8  9 10    8  9 10 11 12 13 14    5  6  7  8  9 10 11
11 12 13 14 15 16 17   15 16 17 18 19 20 21   12 13 14 15 16 17 18
18 19 20 21 22 23 24   22 23 24 25 26 27 28   19 20 21 22 23 24 25
25 26 27 28 29 30 31   29 30 31               26 27 28 29 30
         Oct                    Nov                    Dec
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
                1  2       1  2  3  4  5  6             1  2  3  4
 3  4  5  6  7  8  9    7  8  9 10 11 12 13    5  6  7  8  9 10 11
10 11 12 13 14 15 16   14 15 16 17 18 19 20   12 13 14 15 16 17 18
17 18 19 20 21 22 23   21 22 23 24 25 26 27   19 20 21 22 23 24 25
24 25 26 27 28 29 30   28 29 30               26 27 28 29 30 31
31

have you tried with the following command

cal 10000

Which OS you are using?

I am using HP-UX. See the terminal display snapshot.

$ uname -a
HP-UX adroit B.10.20 A 9000/785 2002974975 one-user license
$ cal 10000
Bad argument
:(:(:frowning:

On HP-UX the year between 1 and 9999.
Refer the link cal - HP-UX

1 Like

.... strange ...

The calendar should be the same every 28 years. So to get the calendar of year 10000 you could just :

cal `expr 10000 - 28`

but i noticed that

cal 1 1900

and

cal 1 1928

gives different results....
... whereas for YYYY above 1901 (and of course until 9999), the commands

cal n YYYY
cal n (YYYY+x*28)

gives the same result

1 Like

Those're pre-1978 dates, so it could be an epoch fail...

No epoch error, just remember the leap year calculations. 1900 was not a leap year (it's a leap year if the year is divisible by 4, but not 100, except when also divisible by 400), and so the time between January 1900 and January 1928 is missing 1 day (February 29th, 1900 doesn't exist). In March of the respective years the calendars match up again.

As for the original question: the man cal (POSIX) utility only has to support dates between September 14, 1752 and December 31, 9999 (both Gregorian calendar):

1 Like

OMG ....
i was not aware of this %100 and %400 tricky subtility in the "leap year" definition ...
Thx for clarification !

chk_leap(){
[[ $(($1%400)) -eq 0 ]] || [[ $(($1%100)) -ne 0 ]] && [[  $(($1%4)) -eq 0 ]] && echo "$1 IS a leap year" || echo "$1 is  NOT leap year"
}
chk_leap "$1"  

:slight_smile:

Remember also that as you go backwards, there are missing days when calendars were 'corrected'.

From "The Mystery of the Missing Days" on www.genealogytoday.com

Personally I can't even remember when I was a lad, but I suppose there may be a need to go back this far and it has been coded by someone.

RBATTE1 @ /usr/home/RBATTE1>cal 1752

                                1752

          January                     February         
Sun Mon Tue Wed Thu Fri Sat  Sun Mon Tue Wed Thu Fri Sat  
             1   2   3   4                            1
 5   6   7   8   9  10  11    2   3   4   5   6   7   8
12  13  14  15  16  17  18    9  10  11  12  13  14  15
19  20  21  22  23  24  25   16  17  18  19  20  21  22
26  27  28  29  30  31       23  24  25  26  27  28  29

           March                        April          
Sun Mon Tue Wed Thu Fri Sat  Sun Mon Tue Wed Thu Fri Sat  
 1   2   3   4   5   6   7                1   2   3   4
 8   9  10  11  12  13  14    5   6   7   8   9  10  11
15  16  17  18  19  20  21   12  13  14  15  16  17  18
22  23  24  25  26  27  28   19  20  21  22  23  24  25
29  30  31                   26  27  28  29  30

            May                         June           
Sun Mon Tue Wed Thu Fri Sat  Sun Mon Tue Wed Thu Fri Sat  
                     1   2        1   2   3   4   5   6
 3   4   5   6   7   8   9    7   8   9  10  11  12  13
10  11  12  13  14  15  16   14  15  16  17  18  19  20
17  18  19  20  21  22  23   21  22  23  24  25  26  27
24  25  26  27  28  29  30   28  29  30
31
           July                        August          
Sun Mon Tue Wed Thu Fri Sat  Sun Mon Tue Wed Thu Fri Sat  
             1   2   3   4                            1
 5   6   7   8   9  10  11    2   3   4   5   6   7   8
12  13  14  15  16  17  18    9  10  11  12  13  14  15
19  20  21  22  23  24  25   16  17  18  19  20  21  22
26  27  28  29  30  31       23  24  25  26  27  28  29
                             30  31
         September                     October         
Sun Mon Tue Wed Thu Fri Sat  Sun Mon Tue Wed Thu Fri Sat  
         1   2  14  15  16    1   2   3   4   5   6   7
17  18  19  20  21  22  23    8   9  10  11  12  13  14
24  25  26  27  28  29  30   15  16  17  18  19  20  21
                             22  23  24  25  26  27  28
                             29  30  31

         November                     December         
Sun Mon Tue Wed Thu Fri Sat  Sun Mon Tue Wed Thu Fri Sat  
             1   2   3   4                        1   2
 5   6   7   8   9  10  11    3   4   5   6   7   8   9
12  13  14  15  16  17  18   10  11  12  13  14  15  16
19  20  21  22  23  24  25   17  18  19  20  21  22  23
26  27  28  29  30           24  25  26  27  28  29  30
                             31

RBATTE1 @ /usr/home/RBATTE1>

Do I get a saddo badge for this? :o

Anyway, I suppose one should ask why you want to get this far through the calendars and see if we can help address that issue.

Robin
Liverpool/Blackburn
UK

Yep, those days are missing because of the correction that was required when switching from the Julian calendar to the Gregorian.

On a side note: today (Feb 15) 30 years ago the British switched to base 10 in their currency. IMO there's a pattern here when it comes to the Empire and international standards :wink:

I think you will find it was forty years ago, i.e. 1971 and before I was born :smiley: it must have been lost in translation somewhere, like the letter u in the correct spelling of colour. :wink:

Robin

You have a strange sense of humor :wink:

But it was 40 years, just after I was born. I'm glad they changed it. I couldn't make head nor tail of it before!