whiplk

[CODE] - DateFormatMask

Jul 12th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.96 KB | None | 0 0
  1. /*
  2.     Coded by: Willian Luigi
  3.     Date format mask.
  4.  
  5.     Function: It verify if the string input got a date format, like DD/MM/YYYY.
  6.         - Verifica se a string inserta na função tem o formato data, tipo DD/MM/AAAA.
  7.  
  8.    
  9. Ex:
  10.  
  11.     04/04/0004 = true
  12.     0/04/0 = false
  13.     04/04/04 = false
  14.     0404040 = false
  15.     04/0404 = false
  16.     amlsdaks = false
  17.     DD/MM/AAAA = false
  18.     2m/2m/20md = false
  19.     /0/203/2 = false
  20.     0004/04/04 = false
  21. */
  22.  
  23. stock readFormat(reader[])
  24. {
  25.     if (reader[0] == '\0' || strfind(reader, "/") == -1) return false;
  26.  
  27.     new
  28.         sS = 0,
  29.         sNextVal[15],
  30.         sOldVal[15],
  31.         sBarFind = 0,
  32.         sV = 2;
  33.        
  34.     format(sOldVal, 15, "%s/", reader);
  35.    
  36.     do
  37.     {
  38.         if ((sS = strfind(sOldVal, "/")) != -1)
  39.         {
  40.             sBarFind ++;
  41.             if (sBarFind == 3) sV = 4;
  42.             strmid(sNextVal, sOldVal, 0, sS);
  43.             strmid(sOldVal, sOldVal, sS + 1, strlen(sOldVal));
  44.             if (!strval(sNextVal) || strlen(sNextVal) != sV) return 0;
  45.         }
  46.     } while(sS > 0);
  47.     return sBarFind == 3;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment