bootstrap-timepicker icon indicating copy to clipboard operation
bootstrap-timepicker copied to clipboard

Added support for a timeSeparator option

Open eleumik opened this issue 11 years ago • 5 comments

Looks like is working, can change ':' with dot '.'. For me is useful to integrate with java locales At line 766 don't know syntax to include separator dynamically in RegEx however there are only two separators in all java locales: ':' and '.'. Next step could be similar work for AM/PM symbol (eg: Arabic م Greek μμ) and (harder perhaps) AM/PM before or after time, in Chinese for example is before 下午9:21

eleumik avatar May 06 '14 21:05 eleumik

Ah.. AM / PM is already a pull request https://github.com/jdewit/bootstrap-timepicker/pull/167/files

eleumik avatar May 06 '14 22:05 eleumik

Where did you get this locale information? I was looking at the CLDR database, but after looking at sq, lt, it, and be, the only one with '.' separator is be, but only for some formats (http://www.unicode.org/cldr/charts/27/summary/be.html#1647).

Otherwise, this seems like a good idea. It is related to #241.

mrhota avatar Aug 12 '15 17:08 mrhota

@mrhota these http://output.jsbin.com/kexil/6 are from Java7, I see dots '.' in sr, it, lt, sq, be.

I use the locale data on the server to parse (the localized version of) the time so had to keep separator.

Should be working in my branch from what I see in the test page

eleumik avatar Aug 18 '15 20:08 eleumik

that's weird. I wonder if the Java locale DB is out of date. CLDR has '.' for timeSeparator in some locales ('be'), but not others in that list.

I think having a timeSeparator option is a requirement for true internationalization, but I want to wait to merge this code until I have a clearer vision of how to include and use CLDR's time data.

I'm also trying to decide whether an optional dependency on jquery Globalize or ECMAScript 6's Intl interface is a good idea.

mrhota avatar Aug 18 '15 21:08 mrhota

As italian, I have almost never seen the '.' ;-) However for Java (tested now with Java 8.45) is that and I had to use that.

As you may have already seen in some issues,

https://github.com/eleumik/bootstrap-timepicker/commits/gh-pages

I had to implement :

  • 12/24h
  • two digits hours
  • configurable time separator
  • configurable meridian separator (x albanian)
  • configurable 'AM/PM' literals (meridian designators)
  • configurable suffix literal (for thai น. at the end)

I stopped at the "'AM/PM' in front" issue, I decided to not support for the moment the timepicker for those languages

I think one should define a reasonable number of these options, call them the "timepicker i18n options", and then whatever source of localization data is chosen, for each source make an adapter that converts to the "timepicker i18n options" format. Sometimes the source is just a pattern that must be parsed, sometimes is a more explicit structure, sometimes one must write code to fix some hard to support cases...I used as source this class http://docs.oracle.com/javase/7/docs/api/java/text/DateFormatSymbols.html

Maybe an other thing to consider is whether one needs/wants to receive/send localized data that must be in some format shared with the server (like me, rare, I am doing it mainly to support no script environment, if you look in the value='' of the examples the values are localized, eg: 05:41 م) or (easier) one gets / sends ISO and so localization is "just" a thing of the UI.

eleumik avatar Aug 19 '15 01:08 eleumik