Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stock ItIsDate(string[]) // YYYY-MM-DD
- {
- new len = strlen(string);
- if(len != 10) return false;
- for(new c; c < len; c++)
- {
- switch(c)
- {
- case 0..3, 5, 6, 8, 9:
- {
- if(string[c] > '9' || string[c] < '0') return false;
- }
- default:
- {
- if(string[c] != '-') return false;
- }
- }
- }
- return true;
- }
- /* Use */
- printf("Date: %s", (ItIsDate("201a-01-20")) ? ("correct") : ("incorrect"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement