[Newbies] How to test a String if it is a valid date?
dnorton at mindspring.com
Wed Mar 30 01:57:37 UTC 2016
On 29 Mar 2016 at 19:07, Joseph Alotta wrote:
> I want to test a String to see if it can be a Date using mm/dd/yyyy
> format. I want something that won´t cause a walkback window. Is
> there a String method isValidAsADate?
You might have a method like this:
"Answer whether aString is in the form 'mm/dd/yyyy' "
| w x |
w := aString asString select: [:a | a isDigit or: a = $/].
x := w findTokens: '/'.
^ x size = 3 and: [w = aString]
This is the general idea. Let me know if you have any questions.
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
More information about the Beginners