Sponsored Content
Top Forums Programming Number of days in month from certain parameters, c programming request. Post 302449226 by fpmurphy on Sunday 29th of August 2010 01:04:50 PM
Old 08-29-2010
Here is a solution which works for the ksh93 shell
Code:
#!/bin/ksh93

year=2010
month=8
dow=4
wom=3

mstr=(jan feb mar apr may jun jul aug sep oct nov dec)
dstr=(sun mon tue wed thu fri sat)
wstr=(1st 2nd 3rd 4th 5th)

dom=$(printf "%(%d)T\n" "${wstr[$wom]} ${dstr[$dow]} ${mstr[$month - 1]} ${year}")

printf "Day of month is: $dom\n"

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Days of the month

Hello, Please can someone help me in getitng last 7 days from the current date? for eg: input /default : today (10/18/2004) required output: 10/17/2004 10/16/2004 10/15/2004 10/14/2004 10/13/2004 ... (6 Replies)
Discussion started by: Anamika
6 Replies

2. Shell Programming and Scripting

Calc number of days in a month

Looking for some help on capturing the number of days in a month to set as a loop counter. Any ideas, please let me know. (3 Replies)
Discussion started by: flounder
3 Replies

3. Shell Programming and Scripting

calculate the number of days left in a month

does any one have any ideas how i would go about calculating the number of days left in the month from a bash script ?. I want to do some operations on a csv file according to the result (8 Replies)
Discussion started by: dunryc
8 Replies

4. Shell Programming and Scripting

Assigning number of days in the month to a variable

I am writing a script that requires the number of days in any given month. In the shell, I can use the command: cal `date +%m` `date +%Y`| grep -v '' | wc -w to give me the number of days in the month, but when I assign it to a variable: VAR=`cal `date +%m` `date +%Y`| grep -v '' | wc... (3 Replies)
Discussion started by: skaptakalian
3 Replies

5. Shell Programming and Scripting

Number of days in the previous month

Hi all. I am scripting in a POSIX shell on HPUX. I am running a script that needs to determine the number of days in a month. I found this on the forum and it works great: X=`cal $(date +%m) $(date +%Y) | grep -v '' | wc -w` The issue is that I am running the script on the 7th day of... (11 Replies)
Discussion started by: lyoncc
11 Replies

6. Shell Programming and Scripting

Number of days in month from certain parameters

Hi, I have an issue in date processing, the issue is I have a month as an int ( 1 - 12 ), the weekday as int ( 0 - 6 , 0 = Sunday), and the week day in month as int ( 0 - 5, 5 = last ex: first sunday, last monday, third tuesday ... ), now from those three parameters is there a possible way to... (5 Replies)
Discussion started by: modn3
5 Replies

7. Shell Programming and Scripting

display number of days in current month

hi all searched google and here, cant find and am begining to suspect there is no options for this. shell = born with either the date or cal command I need to display the number of days in current month. can anyone point me in the right direction? (10 Replies)
Discussion started by: rontopia
10 Replies

8. Shell Programming and Scripting

How to Find number of days in a month in mmddyyyy format?

Hi Guru's, I am working on a shell script from past a month and unable to get rid of automating while working with dates,here's what i have. inital_date=11012011 final_date=11302011 expected_output= has to be in below format PFB 11012011 11022011 11032011 * * * 11102011 * *... (9 Replies)
Discussion started by: Gaurav198
9 Replies

9. Shell Programming and Scripting

Number of days in current month

I have a homework assignment: ---------------------------------------- "Display" the number of days in the current month. For example: September 1996 has 30 days ---------------------------------------- I am trying to just display the head of cal to start the sentence. eg. cal | head ... (1 Reply)
Discussion started by: eaafuddy
1 Replies

10. Shell Programming and Scripting

Convert From Month Number to Month Name

Hi, I have a script that accepts an input date from the user in yyyy-mm-dd format. I need to get the mm-dd part and convert it to month name. example: 2011-11-15 I want that to become "Nov 15" I don't have the GNU date, I am using an AIX os. Thanks. (1 Reply)
Discussion started by: erin00
1 Replies
CALENDAR_CONF(5)					   Sun Grid Engine File Formats 					  CALENDAR_CONF(5)

NAME
calendar_conf - Sun Grid Engine calendar configuration file format DESCRIPTION
calendar_conf reflects the format of the Sun Grid Engine calendar configuration. The definition of calendars is used to specify "on duty" and "off duty" time periods for Sun Grid Engine queues on a time of day, day of week or day of year basis. Various calendars can be imple- mented and the appropriate calendar definition for a certain class of jobs can be attached to a queue. calendar_conf entries can be added, modified and displayed with the -Acal, -acal, -Mcal, -mcal, -scal and -scall options to qconf(1) or with the calendar configuration dialog of the graphical user interface qmon(1). Note, Sun Grid Engine allows backslashes () be used to escape newline ( ewline) characters. The backslash and the newline are replaced with a space (" ") character before any interpretation. FORMAT
calendar_name The name of the calendar to be used when attaching it to queues or when administering the calendar definition. See calendar_name in sge_types(1) for a precise definition of valid calendar names. year The queue status definition on a day of the year basis. This field generally will specify on which days of a year (and optionally at which times on those days) a queue, to which the calendar is attached, will change to a certain state. The syntax of the year field is defined as follows: year:= { NONE | year_day_range_list=daytime_range_list[=state] | year_day_range_list=[daytime_range_list=]state | state} Where o NONE means, no definition is made on the year basis o if a definition is made on the year basis, at least one of year_day_range_list, daytime_range_list and state always have to be present, o all day long is assumed if daytime_range_list is omitted, o switching the queue to "off" (i.e. disabling it) is assumed if state is omitted, o the queue is assumed to be enabled for days neither referenced implicitly (by omitting the year_day_range_list) nor explicitly and the syntactical components are defined as follows: year_day_range_list := {yearday-yearday|yearday},... daytime_range_list := hour[:minute][:second]- hour[:minute][:second],... state := {on|off|suspended} year_day := month_day.month.year month_day := {1|2|...|31} month := {jan|feb|...|dec|1|2|...|12} year := {1970|1971|...|2037} week The queue status definition on a day of the week basis. This field generally will specify on which days of a week (and optionally at which times on those days) a queue, to which the calendar is attached, will change to a certain state. The syntax of the week field is defined as follows: week:= { NONE | week_day_range_list[=daytime_range_list][=state] | [week_day_range_list=]daytime_range_list[=state] | [week_day_range_list=][daytime_range_list=]state} ... Where o NONE means, no definition is made on the week basis o if a definition is made on the week basis, at least one of week_day_range_list, daytime_range_list and state always have to be present, o every day in the week is assumed if week_day_range_list is omitted, o syntax and semantics of daytime_range_list and state are identical to the definition given for the year field above, o the queue is assumed to be enabled for days neither referenced implicitly (by omitting the week_day_range_list) nor explicitly and where week_day_range_list is defined as week_day_range_list := {weekday-weekday|weekday},... week_day := {mon|tue|wed|thu|fri|sat|sun} with week_day ranges the week_day identifiers must be different. SEMANTICS
Successive entries to the year and week fields (separated by blanks) are combined in compliance with the following rule: o "off"-areas are overridden by overlapping "on"- and "suspended"-areas and "suspended"-areas are overridden by "on"-areas. Hence an entry of the form week 12-18 tue=13-17=on means that queues referencing the corresponding calendar are disabled the entire week from 12.00-18.00 with the exception of Tuesday between 13.00-17.00 where the queues are available. o Area overriding occurs only within a year/week basis. If a year entry exists for a day then only the year calendar is taken into account and no area overriding is done with a possibly conflicting week area. o the second time specification in a daytime_range_list may be before the first one and treated as expected. Thus an entry of the form year 12.03.2004=12-11=off causes the queue(s) be disabled 12.03.2004 from 00:00:00 - 10:59:59 and 12:00:00 - 23:59:59. EXAMPLES
(The following examples are contained in the directory $SGE_ROOT/util/resources/calendars). o Night, weekend and public holiday calendar: On public holidays "night" queues are explicitly enabled. On working days queues are disabled between 6.00 and 20.00. Saturday and Sun- day are implicitly handled as enabled times: calendar_name night year 1.1.1999,6.1.1999,28.3.1999,30.3.1999- 31.3.1999,18.5.1999-19.5.1999,3.10.1999,25.12.1999,26 .12.1999=on week mon-fri=6-20 o Day calendar: On public holidays "day"-queues are disabled. On working days such queues are closed during the night between 20.00 and 6.00, i.e. the queues are also closed on Monday from 0.00 to 6.00 and on Friday from 20.00 to 24.00. On Saturday and Sunday the queues are disabled. calendar_name day year 1.1.1999,6.1.1999,28.3.1999,30.3.1999- 31.3.1999,18.5.1999-19.5.1999,3.10.1999,25.12.1999,26 .12.1999 week mon-fri=20-6 sat-sun o Night, weekend and public holiday calendar with suspension: Essentially the same scenario as the first example but queues are suspended instead of switching them "off". calendar_name night_s year 1.1.1999,6.1.1999,28.3.1999,30.3.1999- 31.3.1999,18.5.1999-19.5.1999,3.10.1999,25.12.1999,26 .12.1999=on week mon-fri=6-20=suspended o Day calendar with suspension: Essentially the same scenario as the second example but queues are suspended instead of switching them "off". calendar_name day_s year 1.1.1999,6.1.1999,28.3.1999,30.3.1999- 31.3.1999,18.5.1999-19.5.1999,3.10.1999,25.12.1999,26 .12.1999=suspended week mon-fri=20-6=suspended sat-sun=suspended o Weekend calendar with suspension, ignoring public holidays: Settings are only done on the week basis, no settings on the year basis (keyword "NONE"). calendar_name weekend_s year NONE week sat-sun=suspended SEE ALSO
sge_intro(1), sge__types(1), qconf(1), queue_conf(5). COPYRIGHT
See sge_intro(1) for a full statement of rights and permissions. SGE 6.2u5 $Date$ CALENDAR_CONF(5)
All times are GMT -4. The time now is 05:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy