Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >System Management


    

Blue Forest http://www.lslnet.com at 13:08 on August 8, 2006


Put the date into characters?

I defined the type of input : 2002-08-10 date in the form of how to judge the validity date?
For example : If I illicit importation of other characters (such as : s0f0-02-ds), the date of importation is how to ensure I correct? How to judge?

Put the date into characters?

What in your programming environment.

Put the date into characters?

5.05 SCO UNIX environment

Put the date into characters?

/***********************************************************************/
LEAVES OF 13 SPECIES OF LAURACEAE IsRunNian */ function name :
LEAVES OF 13 SPECIES OF LAURACEAE function : to decide whether or not to introduce Runnian */
LEAVES OF 13 SPECIES OF LAURACEAE format : int IsRunNian Call (i_year) */
LEAVES OF 13 SPECIES OF LAURACEAE input parameters : i_year Year (yyyy) */
LEAVES OF 13 SPECIES OF LAURACEAE return is a leap year : 1 -- */
LEAVES OF 13 SPECIES OF LAURACEAE -1 -- not a leap year */
/***********************************************************************/
Int IsRunNian (int i_year)
{
If (((i_year%4==0) & (i_year%100!=0)) | | (i_year%400==0)) return 1;
Return 1;
}

/***********************************************************************/
LEAVES OF 13 SPECIES OF LAURACEAE CheckDate */ function name :
LEAVES OF 13 SPECIES OF LAURACEAE : functional check on the legality of the date of importation */
LEAVES OF 13 SPECIES OF LAURACEAE Calling format : int CheckDate (s_date) */
LEAVES OF 13 SPECIES OF LAURACEAE s_date input parameters : Date (format yyyymmdd) */
LEAVES OF 13 SPECIES OF LAURACEAE legitimate */ return : 0 --
LEAVES OF 13 SPECIES OF LAURACEAE other -- not legitimate */
/***********************************************************************/
Int CheckDate (char *ylq)
{
Int i, y, m, d,
Int mouth_date[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
Int rc;
  
Char s_date[10];
Char ylq5[5];

If (strlen (ylq) !=10) return 1;
Strncpy (s_date, ylq,4) ;strncpy (ylq5, ylq+5,2) ;strcat (s_date, ylq5);
Strncpy (ylq5, ylq+8,2) ;strcat (s_date, ylq5);
  
For (i=0;i<8;i++) if (!isdigit (s_date[i])) return 2;
I=sscanf (s_date "%4d%2d%2d" &y, &m, &d);
If (i!=3) return 3;
If (m<1||m>;12) return 5.00
Rc=IsRunNian (y);
If (m==2, named rc==1) if (d>;29 | | d<1) return 6;
Else if (d>;mouth_date[m] | | d<1) return 7;
Return 0
}


Put the date into characters?

Alright.



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com