[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Calendar Calculator

Posted on 1998-04-29
9
Medium Priority
?
271 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
  • 5
  • 4
9 Comments
 
LVL 85

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 85

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
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!

 

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 85

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 85

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 85

Accepted Solution

by:
ozo earned 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month19 days, 7 hours left to enroll

834 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