开发者

Localization and Time Format

We know that different locales use different date and number formats, but what about time formats? There are certainly fewer ways to format time values than date values.

I have a field in a web application that accepts a time value as free text, hour and minute only. Suppose that the field allows only one of the following formats for开发者_开发问答 all locales.

  • 23:59
  • 2359
  • 12:59p
  • p12:59

Note that "p" and ":" are customizable for each locale.

Would this be too much restriction for a localizable application supporting non-English locales? I'm asking since there's no built-in parser for time values in JavaScript and it seems that most projects build their own mini parser.


Maybe what you are looking for is JQuery Time Picker. I don't think any of these plugins support JQuery Regional scripts, but at least it should be easier to create your own localized settings instead building a parser... If you still want to build a parser, go for it although trying to support all possible combination (like "6:40", "06:40", "6:40 P.M.") would be at least problematic. As Stefan mentioned, it is easier to do just some kind of drop-down boxes (personally I hate them as they require clicking). Otherwise you may create to text fields: one for hour part and the second one for minutes and add drop-down for selecting AM/PM conditionally (that is if preferred format for this locale is 12 hours).

What about time zones? I'd recommend that the user time zone would be in use, but the time would be then converted to UTC and stored as such internally...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜