Who, in the world, uses DD-YYYY-MM and DD-YY-MM as standard date format patterns? [closed]
Who, in the world, uses DD-YYYY-MM and DD-YY-MM as standard date format patterns?
Should I worry about them?
A quick look into wiki gave me this page
http://en.wikipedia.org/wiki/Date_notation_by_country
there is no one who uses this kind of format. no need to worry I guess.
It depends on what you are getting the date from and what you are allowed to get away with. If this is an application that is going to be used by users who would never enter this type of date and even if they do, you can always return an error, then yes, by all means ignore the format. If, on the other hand, you are writing code that is supposed to read in dates from some unknown data source and it would be a problem if you could not parse a date, then it is probably a very good idea to support the format.
It comes down to the argument of programming by contract vs. defensive programming. If you don't support DD-YY-MM, then your application will not work right that one time in 3 years that something gives it that form of date. If this is acceptable or not worth the cost, than by all means ignore it.
My general rule-of-thumb regarding date parsing is, if strtotime
can't handle it, toss it out and make them type a new one. This may be different for whatever language you're using, but there's probably a library/function that parses datetimes for you so you don't have to worry about it. No need to reinvent the wheel.
精彩评论