Solved

Calendar Calculator

Posted on 1998-04-29
9
267 Views
Last Modified: 2013-12-03
I am in need of some sort of calendar calulator.  From within a shell script i set a variable to a date by using the date command.  I then need to be able to set another variable to a date that is 2 weeks ( 14 days) later.  I will then compare this new date to the current date to determine if this item is overdue.  I would then issue some kind of email message to the particular party.  Is there such a tool available, or is it possible all within shell scripts?
0
Comment
Question by:j_k
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 2006540
I don't understand what you want to do.
If you set a variable to the current date, and another variable to a date 14 days later, then don't you already know how they compare?

0
 

Author Comment

by:j_k
ID: 2006541
Hello Ozo,

Sorry, The second date variable would have to be calculated from value of the 1st date variable that was contained in a text file.  Example: something like this!

The data file would look something like this:
submittal1|04/20/98|
submittal2|04/24/98|
submittal3|04/28/98|
... and so on ....

and the script would do something like this:
for each LINE in data file

SUBMITTAL=??? (awk on LINE getting 1st column)
ENTERED_DATE=04/20/98 (awk on LINE getting 2nd column)
RESPOND_DATE=???  (a calculated date 2 weeks after the entered_date)

if (today's date) is > respond_date then
  send email notifying user that the submittal $SUBMITTAL
  that was due on $RESPOND_DATE is overdue

Hope this helps
JAK


0
 
LVL 84

Expert Comment

by:ozo
ID: 2006542
I could suggest an answer, but I'm afraid you may have a problem with it about 600 days later...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:j_k
ID: 2006543
Thats Ok, This program may be need then.  But for now it
sure would be helpful, in the ways we are doing things now!.

Is this a good place for perl?

0
 
LVL 84

Expert Comment

by:ozo
ID: 2006544
Yes, using Time::Local::timelocal in perl would have been one of my suggestions.
(Setting a large time zone offset or Zeller's congruence would have been the others)

I have to go for now, but I'll try to be back later if you need more specific help.
0
 

Author Comment

by:j_k
ID: 2006545
Yes, please expand on the perl solution.

0
 
LVL 84

Expert Comment

by:ozo
ID: 2006546
use Time::Local;
$now = time;
while( <> ){
        ($ss,$mm,$dd,$yy)=split('[/|]');
        $due = timelocal(0,0,6,$dd,$mm-1,$yy)+60*60*24*14;
        next if $due > $now;
        ($date=localtime($due))=~s/ \d\d:\d\d:\d\d/,/;
        open(M,"|/usr/lib/sendmail -t") || warn $!;
        print M "To: $user\nSubject: overdue\n\nsubmittal $ss that was due on $date is overdue\n";
        close M || warn $!;
}
0
 

Author Comment

by:j_k
ID: 2006547
Thanks again, just what i needed.



0
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 2006548
Ok, shall we call it an Answer then?

BTW, except for generating the "due on $date" part of the message
you might even have gotten by without using Time::Local
with something like:

($dd,$mm,$yy)=(localtime time-60*60*24*14)[3,4,5];
$old = sprintf"%d%02d%02d",$yy+1900,$mm+1,$dd;
while( <> ){
    ($ss,$mm,$dd,$yy)=split('[/|]');
    next if $old < sprintf"%d%02d%02d",$yy+1900,$mm,$dd;
    open(M,"|/usr/lib/sendmail -t") || warn $!;
    print M "To: $user\nSubject: overdue\n\nsubmittal $ss that was due 14 days after $mm/$dd/$yy is overdue\n";
    close M || warn $!;
}
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Google Analytics - viewing a page 10 83
Saving Web Page as PDF 9 80
javascript form - error when hitting enter 3 46
Selenium cssSelector and attribute 5 11
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question