Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Format DateTime Auto Locale
larrychan
My database has a date time column that I'm displaying it as a table in my report. I set the Format DateTime section of the data element to be "Format as: Unformatted" and "Locale: Auto". I read the documentation that if I set the locale to auto, it'll display the date time value in the "locale of the user's machine". I just want to be clear if I understand the phrase correctly.
I have a US user running the report, he/she will see dates in Month-Day-Year. I have a 2nd user in UK running the same report, he/she will see dates in Day-Month-Year.
Is my understanding above correct? If so, is the browser passing the locale somewhere in the http headers so that the report engine knows what locale the user is in?
Thanks in advance.
Find more posts tagged with
Comments
kclark
I think that will end up being the server locale you could use some client side scripting like this to get the locale from the browser.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>function getLocale() {
var locale1 = navigator.language;
alert(locale1);
}</pre>
<br />
And then change the locale of the report from script based on what's returned.
larrychan
Specifically, do I do the following?
1. In the report's beforeFactory method, add the JavaScript you suggested. Set the value into a variable.
2. Then change the reports locale based on the value of the variable.
My question is that for #1, the JavaScript is run inside the report engine. Would it be able to get the locale of the browser correctly?
And for #2, is there a particular property/attribute of the report that I'm setting the locale?
kclark
I haven't tried it yet but you should be able to get the locale from an html landing page with navigator.language then forward the user to your report. For me that returns en-US. You would need to pass it in the URL using &__locale=YOURLOCALE so it would look something like this.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<html>
<head>
<script>
function getLocaleAndForward() {
var myLocale = navigator.language;
var url = "http://localhost:8080/viewer/frameset?__report=myreport.rptdesign&__locale=" + myLocale;
window.location(url);
}
</script>
</head>
<body onLoad="getLocaleAndForward();">
<h1>Loading report...</h1>
</body>
</html></pre>