开发者

Who, in the world, uses DD-YYYY-MM and DD-YY-MM as standard date format patterns? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago. 开发者_JS百科

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜