JavaScript implementation of the ICU (International Components for Unicode) that uses the Common Locale Data Repository to format dates, plurals, and more. Based on twitter-cldr-rb.
When tested with a code like the following to check the additional date_time formats
//Additional Date and Time Formats
var fmt = new TwitterCldr.DateTimeFormatter();
var addlFormats = TwitterCldr.DateTimeFormatter.additional_formats();
var addlFormatsLength = addlFormats.length;
if (addlFormatsLength > 0) {
combStr = combStr + "<h3>Additional Date and Time Formats</h3></br>";
combStr = combStr + "<table><tr><th>Format</th><th>Output</th></tr>";
var addlFormatDict = {};
addlFormatDict["format"] = "additional";
for (var i = 0; i < addlFormatsLength; i++) {
addlFormatDict["type"] = addlFormats[i];
if (i%2) {
combStr = combStr + "<tr class='alt'><td>" + addlFormats[i] + "</td><td>" + fmt.format(new Date(), addlFormatDict).toString() +"</td></tr>";
} else {
combStr = combStr + "<tr><td>" + addlFormats[i] + "</td><td>" + fmt.format(new Date(), addlFormatDict).toString() +"</td></tr>";
}
}
combStr = combStr + "</table></br>";
}
The following output was given in ar locale
Format Output
EHm EHH:mm
EHms E HH:mm:ss
Ed E، d
Ehm E h:mm a
Ehms E h:mm:ss a
Gy y G
GyMMM MMM y G
.
.
.
But this is not the expected output, we would like to have formatted date as output, not just plain text format string.
Here we can see that they are mixing up pattern and and plaintext, pattern for items which need substitution and plain text for items which should be output just like that.
This means that for the "EHm" format in ar will output the plain text "E:HH:mm" (which is currently happening), where as we would like to have substitution for the patterns to happen, like the "long" example given
Can you look into this to check if this is a bug ? The code behaves the same for all "additional" date_time formats for all locales which makes me wonder whether this is intentional or not....
Hey @surebee thanks for the bug report. As I recall, we ran into the same issue in the Ruby version of this library a little while ago. I'll take a look as soon as I can!
HI,
When tested with a code like the following to check the additional date_time formats
The following output was given in ar locale
Format Output EHm EHH:mm EHms E HH:mm:ss Ed E، d Ehm E h:mm a Ehms E h:mm:ss a Gy y G GyMMM MMM y G . . . But this is not the expected output, we would like to have formatted date as output, not just plain text format string.
Looking into the code for ar.js
"date_time" "long" format...
"long":[{"value":"d","type":"pattern"},{"value":" ","type":"plaintext"},{"value":"MMMM","type":"pattern"},{"value":"، ","type":"plaintext"},{"value":"y","type":"pattern"},{"value":" ","type":"plaintext"},{"value":"h","type":"pattern"},{"value":":","type":"plaintext"},{"value":"mm","type":"pattern"},{"value":":","type":"plaintext"},{"value":"ss","type":"pattern"},{"value":" ","type":"plaintext"},{"value":"a","type":"pattern"},{"value":" ","type":"plaintext"},{"value":"z","type":"pattern"}]
Here we can see that they are mixing up pattern and and plaintext, pattern for items which need substitution and plain text for items which should be output just like that.
but for "date_time" "additional" format...
"additional":{"EHm":[{"value":"E","type":"plaintext"},{"value":" ","type":"plaintext"},{"value":"H","type":"plaintext"},{"value":"H","type":"plaintext"},{"value":":","type":"plaintext"},{"value":"m","type":"plaintext"},{"value":"m","type":"plaintext"}]
This means that for the "EHm" format in ar will output the plain text "E:HH:mm" (which is currently happening), where as we would like to have substitution for the patterns to happen, like the "long" example given
"additional":{"EHm":[{"value":"E","type":"pattern"},{"value":" ","type":"plaintext"},{"value":"HH","type":"pattern"},{"value":":","type":"plaintext"},{"value":"mm","type":"plaintext"}]
Output behaves right once this change is done.
Can you look into this to check if this is a bug ? The code behaves the same for all "additional" date_time formats for all locales which makes me wonder whether this is intentional or not....