[Javascript] chopping up a string?
Hassan Schroeder
hassan at webtuitive.com
Mon Nov 17 09:40:45 CST 2003
Paul McGuire wrote:
> one in the string it may well be that a 1711 or 17 has been
> entered instead of a "proper date format". So we will assume the string
> entered needs to be converted - for example 1711 to 17/11/03
>
> if we divide the input by 2 we will get the number of dateparts in the
> string - the number of characters in the string "17" divides by 2 once so we
> know there is only a day of month in that string. The 17th. characters in
> "1711" divides by 2, 2 times, so we can assume we have a day of month and a
> month -17th of November in this example
Is the audience for this function highly technical -- will /always/
pad single-digit date values with 0? And all from parts of the world
that format dates dd/mm/yy?
What's `11`? November, the first of January, the 11th of this month?
What's `43`? The third of April or 4th of March, or gibberish?
What's 108? Tenth of August, 8th of October, 8th of January?
You'd probably save yourself a *lot* of coding, and eliminate a
possible source of user confusion, by having separate `day` and
`month` fields :-)
FWIW!
--
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design === (+1) 408-938-0567 === http://webtuitive.com
dream. code.
More information about the Javascript
mailing list