Sponsored Content
Full Discussion: get next working day
Top Forums Programming get next working day Post 302272673 by jim mcnamara on Wednesday 31st of December 2008 10:11:38 AM
Old 12-31-2008
fpmurphy gave you a very reasonable response based on your requirements.

I work in calendrics a lot, and the requirements you stated for the
definition of a "business day" were either very naive, or for a country
I have never done work for. In most places there are a lot of other
considerations as to what the definition of a "business day" is.

One reason is because the requirment doesn't take holidays and religious
observances into account. Holidays are never trivial, they are often
very local and often based on a distinctly non-Gregorian lunar
calculation. So there is no general method presented very often.

The other issue is that programmers think they "know" calendars
because they grew up with them, but may not know what calendars really do..
Even for the Gregorian calendar. Read the langinfo man page. Look at
the output of
Code:
 cal 9 1752

Do you know why September seems wrong?
And if you live in France that output of cal is wrong.

Holidays --
One way is parse a tztab-like file, then write code: maybe a "isholiday(struct
tm *)" function to parse the table the against a given date:

Quote:
# The first six fields specify the first minute in which a holiday
# specified in the seventh field, applies. The fields are
# separated by spaces or tabs. The first six are integer patterns that
# specify the minute (0-59), hour (0-23), day of the month (1-31), month
# of the year (1-12), year (1970-2038), and day of the week (0-6, with
# 0=Sunday). The minute, hour, and month of the year must contain a
# number in the (respective) range indicated above. The day of the
# month, year, and day of the week can contain a number as above or two
# numbers separated by a minus (indicating an inclusive range). Either
# the day of the month or the day of the week field must be a range, the
# other must be simple number.
#
#
# Holiday table - partial table example
MST7MDT
#minute
# hour
# DOM
# month
# year
# DOW
0 0 25 12 1990-2038 1-5 christmas
0 0 24 12 1990-2038 1-5 christmas eve
0 0 26 12 1990-2038 1 christmas on sunday
0 0 23 12 1990-2038 5 christmas eve on saturday
0 0 4 7 1990-2038 1-5 july 4
0 0 3 7 1990-2038 5 july 4 on saturday
0 0 5 7 1990-2038 1 july 4 on sunday
0 0 25-31 5 1990-2038 1 Memorial day always on the last monday of may
0 0 15-21 1 1990-2038 1 MLK day 3rd Monday in April
0 0 1-7 9 1990-2038 1 Labor day 1st Monday in Sept
0 0 E-2 0 0 0 Good Friday two days before easter
The E-2 entry is a paschal lunar easter algorithm for western Easter
(as opposed to Orthodox Easter) - the entry above returns two days
before Easter. Lunar holidays and very important religious observances
usually require special algorithms.

The table also deals with moving holidays onto work days, like observing
July 4th (a US holiday) on July 5 or on July 3 because July 4 is on a weekend.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Write a shell script to find whether the first day of the month is a working day

Hi , I am relatively new to unix... Can u pls help me out to find out if the first day of the month is a working day ie from (Monday to Friday)...using Date and If clause in Korn shell.. This is very urgent. Thanks for ur help... (7 Replies)
Discussion started by: phani
7 Replies

2. Shell Programming and Scripting

set Working day in ksh

Hello guys it´s a pleasure to type with the unix community...I´m new in shell script and I need to insert into a #!/ksh a statment that will check if a file that I´ll receive from another script is arriving in the first working day of each month: let´s say that I´ll reveive the following files... (1 Reply)
Discussion started by: Rafael.Buria
1 Replies

3. Shell Programming and Scripting

Get Last working day of the month

Hi I need a script to get "Last working day of the month". I will pass the month and year as parameters and i need to get the last working date. Ex for June 2008 the last working day is 30th its monday. for August 2008 the last working day is 29th and it is Friday. ie the last working... (6 Replies)
Discussion started by: manmarirama
6 Replies

4. Shell Programming and Scripting

last working day of previous month

Hi, I want a script(ksh) to see if today is the last working day(Mon-Fri) of the month. If it is the last working day I need to print current date, else I need the last working day of previous month. Thanks in advance. (1 Reply)
Discussion started by: rspk_praveen
1 Replies

5. Shell Programming and Scripting

Script to find previous month last day minus one day timestamp

Hi All, I need to find the previous month last day minus one day, using shell script. Can you guys help me to do this. My Requirment is as below: Input for me will be 2000909(YYYYMM) I need the previous months last day minus 1 day timestamp. That is i need 2000908 months last day minus ... (3 Replies)
Discussion started by: girish.raos
3 Replies

6. Shell Programming and Scripting

How to find the first working day of month ?

Hi, How to find the first working day of month ? My requirement is, I need to call the function only if today is first working day of month. I could find out one function which finds last working day in month in this forum. Can anyone pls let me know for first working day. Thanks. for... (10 Replies)
Discussion started by: vnimavat
10 Replies

7. Shell Programming and Scripting

Calculating 12th working day

I have a business requirement in my project where I need to calculate the 12th working day of every month. Can any please tell me the solution to my problem. Thanks in advance (7 Replies)
Discussion started by: ami_smart
7 Replies

8. UNIX for Dummies Questions & Answers

Running Script via Crontab on 2nd Working day each month

Hello Guys, I have a questions regarding running a shell script every second working day each month. I have no clue how solve this problem :wall:. Important is that it has to be the second working (Mo-Fr). Example: If 1st and 2nd Days of month are Sat and Sun the script must run on 4th day... (5 Replies)
Discussion started by: Hollo
5 Replies

9. Shell Programming and Scripting

Find Month first Working Day

Hi, I would like to calculate 1st working/Business day of each month. Exp: 1st -Oct-2011 is Saturday--- Non Business Day So the Next Working Day would be 3-Oct-2011 I need a shell script to calculate the month first business date. (3 Replies)
Discussion started by: koti_rama
3 Replies

10. Shell Programming and Scripting

KSH script Not working (calculate days since 1/1/2000 given day 4444)

I am unable to get this KSH script to work. Can someone help. I've been told this should work with KSH93. Which I think I have on Solaris 10. If I do a grep -i version /usr/dt/bin/dtksh I get @(#)Version M-12/28/93d @(#)Version 12/28/93 @(#)Version M-12/28/93 This is correct for... (5 Replies)
Discussion started by: thibodc
5 Replies
widget_calendar(n)					    widget::calendar Megawidget 					widget_calendar(n)

__________________________________________________________________________________________________________________________________________________

NAME
widget_calendar - widget::calendar Megawidget SYNOPSIS
package require Tcl 8.4 package require Tk 8.4 package require widget ?3.0? widget::calendar pathname ?options? _________________________________________________________________ DESCRIPTION
This package provides a calendar megawidget (snidget). widget::calendar pathname ?options? WIDGET OPTIONS
-command A script to evaluate when a date was selected. -dateformat The format of the date that is returned. Default: %m/%d/%Y. -firstday Set first day the week, Either sunday or monday. It defaults to monday. -font Select the font used in the widget. It defaults to Helvetica 9. -highlightcolor Selects the background color for the day that has been selected. Default: #FFCC00 -language Specify language of the calendar contents. The language is specified by abbreviations of the languge, for example: en - english, de - german ... It defaults to en. Supported languages: en, de, fr, it, es, pt, ru, sv, zh, fi -shadecolor Selects the color of the parts that have a shaded background. Default: #888888 -showpast Specify if the past shall be shown. It is a boolean value and defaults to 1. -textvariable Specifies the name of a variable whose value is linked to the entry widget's contents. Whenever the variable changes value, the widget's contents are updated, and vice versa. WIDGET COMMAND
pathname get ?what? Returns a part of the selected date or 'all'. The argument what selects the part. Valid values for what are: day, month, year and all. 'all' is the default and returns the complete date in the format given with -dateformat. DEFAULT BINDINGS
On creation of the calendar widget the following bindings are installed. o Up - Move to week before current date o Down - Move to week after current date o Left - Move to day before current date o Right - Move to day after current date o Control-Left - Move to month before current date o Control-Right - Move to month after current date o Control-Up - Move to year before current date o Control-Down - Move to year after current date EXAMPLE
package require widget::calendar ; # or widget::all set t [widget::calendar .t] pack $t -fill x -expand 1 KEYWORDS
megawidget, snit, widget widget 0.93 widget_calendar(n)
All times are GMT -4. The time now is 02:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy