Find the answer to your Linux question:
Results 1 to 3 of 3
I'm attempting to script an application for the bash shell. The application needs to check for birthday, but must check the birthday to see if the date is a) in ...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    4

    Checking for future / non existent dates

    I'm attempting to script an application for the bash shell. The application needs to check for birthday, but must check the birthday to see if the date is a) in the future b) exists at all (ie Feb 29th during non-leap years). The input is being entered in a YYYYMMDD format, so I was hoping someone could point me in the direction for how to check for future dates and non-existent dates.

    Thanks
    - D

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    This is fairly easy to do in a bash shell script.

    A good place to start is to do this on the command line:
    Code:
    man bash
    Then check out the tutorials by googling this:
    Code:
    bash tutorial
    Sounds like an interesting homework assignment!

  3. #3
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    Quote Originally Posted by DKNUCKLES View Post
    I'm attempting to script an application for the bash shell. The application needs to check for birthday, but must check the birthday to see if the date is a) in the future b) exists at all (ie Feb 29th during non-leap years). The input is being entered in a YYYYMMDD format, so I was hoping someone could point me in the direction for how to check for future dates and non-existent dates.

    Thanks
    - D
    you can use GNU date to check valid dates:
    Code:
    # date --date='29 Feb'
    date: invalid date `29 Feb'
    please see the man page of date for more info and examples

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...