Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for a timeSeparator option #226

Open
wants to merge 17 commits into
base: gh-pages
Choose a base branch
from

Conversation

eleumik
Copy link

@eleumik eleumik commented May 6, 2014

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

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
Copy link
Author

eleumik commented May 6, 2014

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

eleumik added 15 commits May 8, 2014 21:51
with some changes for variable length... eg: Czech [dop., odp.]
"When the time is greater than 11 you will notice that the meridian is ALWAYS AM when it should be PM." - Also if is true that if when use meridian there should be not an input hour > 12 is handy that is automatically understood and converted, in my opinion better than setting to 12 whatever hour > 12 is configured
When setting hour to zero or 24 the time was incorrect.  was setting hour to 23 when >=24 but should be zero. Now printing 25 controls with time from 0 to 24 gives correct results for all, in 24h mode, in 12h is still wrong: for 0 prints 01 AM (like for 1 and 24)
Should be ok, 12 AM for both 0 and 24, with a little help from wiki.. http://en.wikipedia.org/wiki/12-hour_clock
added configuration from data attributes with priority on code (code can change or remove them, so may re-obtain control), also a fix for 12 AM / PM (not zero) and a note for orientation (cannot reproduce yet)
Missed the regexp, now updated to match designator and not 'p', thought also that removing both ':' and '.' is ok.
When the widget is localized is handy to read the ISO 8601 value [hh:mm:ss] http://en.wikipedia.org/wiki/ISO_8601#Times
Noticed that calling getTime did not return the time but jquery object, plugin has still some magic for me but found this http://stackoverflow.com/a/17792070/1536382 and chose to return first item only
didn't realize it was already there.. left some since have to update examples because names are different..they act for now as sort of preferred option, eg: data-am wins on 'standard-name' data-am-designator
to know if am, only when showMeridian==true
**MeridianSeparator** is to support '.' for Albanian locale (sq, sq_AL).

**SubmitMode** determines the value actually submitted with the form and has 3 values: 
    
    'default' (as before, untouched, same as display value)
    'iso' (ISO8601, always with seconds)
    'iso-auto' (ISO8601, with seconds only if displayed)
suffix is used only for Thai locale with value " น.", if is not present java DateFormat wont' parse the time (if has no seconds)

merged also orientation
@mrhota
Copy link
Collaborator

mrhota commented Aug 12, 2015

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 mrhota mentioned this pull request Aug 12, 2015
@eleumik
Copy link
Author

eleumik commented Aug 18, 2015

@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

@mrhota
Copy link
Collaborator

mrhota commented Aug 18, 2015

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.

@eleumik
Copy link
Author

eleumik commented Aug 19, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants