LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 06-07-2006, 07:27 PM   #1
Blackout_08
Member
 
Registered: Jan 2004
Posts: 35

Rep: Reputation: 15
Check for invalid date


ok im trying to figure out how to determine if a date YYYYMMDD is invalid without checking if YYYY is greater than 0, MM is greater than 0 and less than 12, and DD is greater than 0 and less then 31/30/29/28. Any ideas?
 
Old 06-07-2006, 08:30 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Which language are you using? Some have builtin function to do that sort of work for you.
 
Old 06-07-2006, 08:36 PM   #3
Blackout_08
Member
 
Registered: Jan 2004
Posts: 35

Original Poster
Rep: Reputation: 15
/bin/bash is used
 
Old 06-07-2006, 09:28 PM   #4
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 34
try
Code:
touch -t $DATE  dummy_file
if [ $? -ne 0 ] ; then
  echo "Invalid date"
fi
If you try to use an invalid date touch will return a non-zero value
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Start Date + Time Duration = End Date/Time calculator? ToBe Linux - General 3 09-26-2005 11:17 AM
glibc 2.3.5 "make check" invalid multibyte sequence sundialsvcs Linux - Software 8 09-09-2005 10:56 AM
squirremail ...it says invalid user or invalid password. rnj Fedora 9 10-25-2004 10:56 PM
Boot disk; check. CD in drive; check. Doesn't work; check. Hal DamnSmallLinux 7 02-04-2004 03:10 AM
lastlog date does not match system date? jcmj Linux - Networking 6 10-22-2002 01:09 PM


All times are GMT -5. The time now is 10:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration