calendar in unix


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users calendar in unix
# 1  
Old 02-15-2011
calendar in unix

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

Code:
$ 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


Last edited by pludi; 02-15-2011 at 07:43 AM.. Reason: code tags, please...
# 2  
Old 02-15-2011
MySQL

have you tried with the following command
Code:
cal 10000

Which OS you are using?
# 3  
Old 02-15-2011
Re: calendar in unix

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
SmilieSmilieSmilie


# 4  
Old 02-15-2011
MySQL

On HP-UX the year between 1 and 9999.
Refer the link cal - HP-UX
This User Gave Thanks to ungalnanban For This Post:
# 5  
Old 02-15-2011
.... strange ...

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

Code:
cal `expr 10000 - 28`

but i noticed that
Code:
cal 1 1900

and
Code:
cal 1 1928

gives different results....
... whereas for YYYY above 1901 (and of course until 9999), the commands
Code:
cal n YYYY
cal n (YYYY+x*28)

gives the same result

Last edited by ctsgnb; 02-15-2011 at 10:42 AM..
This User Gave Thanks to ctsgnb For This Post:
# 6  
Old 02-15-2011
Those're pre-1978 dates, so it could be an epoch fail...
# 7  
Old 02-15-2011
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 cal utility only has to support dates between September 14, 1752 and December 31, 9999 (both Gregorian calendar):
Quote:
The cal utility shall write a calendar to standard output using the Julian calendar for dates from January 1, 1 through September 2, 1752 and the Gregorian calendar for dates from September 14, 1752 through December 31, 9999 as though the Gregorian calendar had been adopted on September 14, 1752.

Last edited by pludi; 02-15-2011 at 11:57 AM.. Reason: clarification
This User Gave Thanks to pludi For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Autosys - Extended Calendar

Does anyone know if you can create an Extended Calendar in Autosys that will do the following...Schedule on the last business day of the month, but if the last business day falls on a Mon-Thur...schedule on the next business day (1st of the next month) ? (1 Reply)
Discussion started by: amarq0004
1 Replies

2. Shell Programming and Scripting

sort calendar files

I have a few .calendar files /usr/share/calendar they look like 01/01<TAB>Anniversary of the Triumph of the Revolution in Cuba 01/24<TAB>Gold discovered in California at Sutter's Mill, 1848 01/28<TAB>First ski tow, Woodstock VT, 1914 01/28<TAB>Space Shuttle Challenger (51-L) explodes 74... (2 Replies)
Discussion started by: p100x1
2 Replies

3. Shell Programming and Scripting

Calendar AWK

Hi, how should I use system command cal (calendar) in awk?, I have try several combinations and none works. Here what I have done. awk -f '{print cal}' awk -f '{print 'cal'}' awk -f '{print "cal"}' awk -f {print cal} Regards. (2 Replies)
Discussion started by: Godie
2 Replies

4. Shell Programming and Scripting

Help with filtering dates from the calendar

Hi, I need a simple shell script to help filter weekends from the calendar of a month. In other words, i need a script to identify the working days in a month. (3 Replies)
Discussion started by: pravsripad
3 Replies

5. Web Development

Calendar on web - newbie

Hi folks, I am kind of new to these things. I want to create a web based database which will serve as a sort of vacation calendar for the employees so that we know how many men we have at a given date. We want this to be seen on internal pages only, so it will be accessed by a username and... (3 Replies)
Discussion started by: apprentice
3 Replies

6. Shell Programming and Scripting

autosys calendar

Hi, Is there any autosys calendar for last day of a month(irrespective of holidays) For eg., Jan 31, Feb 28(29), Mar 31, Apr 30 ... Thanks in Advance (2 Replies)
Discussion started by: rspk_praveen
2 Replies

7. UNIX for Dummies Questions & Answers

what command can show calendar in unix system?

what command can show calendar in unix system? (2 Replies)
Discussion started by: kennethchow
2 Replies
Login or Register to Ask a Question