I'm using JQuery Calendars to produce date strings for an application. If I set the language to English, I get a date string like this:
Friday • October 10 2014
JQ Calendars doesn't handle times, so I format the time portion of the string myself:
[ • 12:00 am UTC-04:00]
(brackets are included for clarity; they won't be part of the final string.) Next, I just add these two strings together, and get:
Friday • October 10 2014[ • 12:00 am UTC-04:00]
which is exactly what I want. However, when I do the same thing with language set to Hebrew, my results are:
שישי • 10 אוקטובר 2014
[ • 12:00 am UTC-04:00]
שישי • 10 אוקטובר 2014[ • 12:00 am UTC-04:00]
Note the odd intercalation of the timestring between the RTL Hebrew month and year.
I've tried wrapping portions of both strings in directional codes (U+202A, U+202C, etc.) without success. It looks like the date string is a mix of RTL and LTR already, but I've searched through it and can't find any directional characters, although I may well be bodging this search.
Any thoughts on how to fix this? For better or worse, I want the time string to "follow" the date string without the weird break, even though this may not be technically correct. I'm aware of Javascript's toLocaleString() functionality, but it isn't well supported yet, so I'd like to use the approach above at least as a fallback.
I solved this. It turns out that Hebrew isn't strictly RTL; numeric portions of strings are rendered LTR, even though words and sentences are rendered RTL. So the results shown above are "correct," in the sense that I was appending my time string onto the "end" of the date string - which occurs immediately to the right of the final numeral in the year, 2014.
Generating the date string with the space and bullet character as part of the formatting, via JQ Calendars, "resets" the formatting so the end of string follows, to the left, of the year. Doing an explicit embed of the time string, preceded by 'U+202A', plunks the time string as a whole following the date string, without intercalating the result. In the end, I wind up with
الجمعة • 10 تشرين الأول 2014 • 12:00 am UTC-04:00
which, though not strictly RTL, serves my purposes just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With