I have ASP.NET MVC 5 application, and my Globalization / Validation (Globalize 1.2.2) loads are:
<script src="~/Scripts/cldr.js"></script>
<script src="~/Scripts/cldr/event.js"></script>
<script src="~/Scripts/cldr/supplemental.js"></script>
<script src="~/Scripts/globalize.js"></script>
<script src="~/Scripts/globalize/number.js"></script>
<script src="~/Scripts/globalize/date.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.globalize.js"></script>
<script type="text/javascript">
$.when(
$.getJSON("@Url.Content("~/Scripts/cldr/supplemental/likelySubtags.json")"),
$.getJSON("@Url.Content("~/Scripts/cldr/supplemental/numberingSystems.json")"),
$.getJSON("@Url.Content("~/Scripts/cldr/supplemental/timeData.json")"),
$.getJSON("@Url.Content("~/Scripts/cldr/supplemental/weekData.json")"),
$.getJSON("@Url.Content("~/Scripts/cldr/main/en/numbers.json")"),
$.getJSON("@Url.Content("~/Scripts/cldr/main/en/ca-gregorian.json")"),
$.getJSON("@Url.Content("~/Scripts/cldr/main/en/timeZoneNames.json")"),
$.getJSON("@Url.Content("~/Scripts/cldr/main/sr-Latn/numbers.json")"),
$.getJSON("@Url.Content("~/Scripts/cldr/main/sr-Latn/ca-gregorian.json")"),
$.getJSON("@Url.Content("~/Scripts/cldr/main/sr-Latn/timeZoneNames.json")")
).then(function () {
console.log("start slicing");
return [].slice.apply(arguments, [0]).map(function (result) {
console.log("slicing done");
return result[0];
});
}).then(Globalize.load).then(function () {
Globalize.locale('sr-Latn');
}).then(console.log("LOADED EVERYTHING"));
</script>
But now, when I try to test in browser debugger, the command:
Globalize.formatDate(new Date(), {datetime:"long"});
gives unexpected result. Instead colon as time separator, I got a dot: "16. januar 2017. 07.57.17 GMT+1". JSON repository looks OK in "timeFormats" and "dateTimeFormats" patterns. Everything is OK with "en", or "de", which has similar time and date patterns defined in repository.
Where am I wrong?
The dot isn't a separator, but part of the long datetime format.
The "16. januar 2017. 07.57.17 GMT+1"
output you get for the long datetime format of "sr-Latn"
locale is composed of (a) "16. januar 2017.
long date format, (b) a space separator " "
, and (c) "07.57.17 GMT+1"
long time format.
Note dateTimeFormats.long = "{1} {0}"
is what glues date and time (i.e., space separator), dateFormats.long = "dd. MMMM y."
(i.e., there's a dot after year), and timeFormats.long = "HH:mm:ss z"
.
The dots used as time separator comes from "timeSeparator": "."
.
Having said that, if you believe the dot after year is incorrect OR if the separator should be a comma instead of space, please file a ticket into CLDR: http://unicode.org/cldr/trac/newticket