whiplk

[CODE] - DateFormatMask(v2)

Jul 13th, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.86 KB | None | 0 0
  1. //Coded by: Willian Luigi
  2. stock readFormat(reader[])
  3. {
  4.     if (reader[0] == '\0' || strfind(reader, "/") == -1) return false;
  5.  
  6.     new
  7.         sS = 0,
  8.         sNextVal[15],
  9.         sOldVal[15],
  10.         sBarFind = 0,
  11.         sV = 2;
  12.        
  13.     strcat(sOldVal, reader);
  14.     sOldVal[strlen(sOldVal)] = '/';
  15.     do
  16.     {
  17.         if ((sS = strfind(sOldVal, "/")) != -1)
  18.         {
  19.             sBarFind ++;
  20.             if (sBarFind == 3) sV = 4;
  21.             strmid(sNextVal, sOldVal, 0, sS);
  22.             if (!strval(sNextVal) || strlen(sNextVal) != sV) return false;
  23.             switch(sBarFind)
  24.             {
  25.                 case 1: if (!(0 < strval(sNextVal) < 32)) return false;
  26.                 case 2: if (!(0 < strval(sNextVal) < 13)) return false;
  27.                 case 3: if (!(1905 < strval(sNextVal) < 2005)) return false;
  28.                 default: return false;
  29.             }
  30.             strmid(sOldVal, sOldVal, sS + 1, strlen(sOldVal));
  31.         }
  32.     } while(sS > 0);
  33.     return sBarFind == 3;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment