Is it possible to determine regional settings of the client's machine, using pure javascript? I need to get first day of the week. Is it Sunday or Monday.
-
Is that supposed to be some settings that you set on OS? Never heard of such a setting before. – mmhan Sep 19 '11 at 16:21
-
yep. I don't know bout others but in Windows there is one – iLemming Sep 19 '11 at 16:40
-
1If google isn't doing it for google calendar, I suppose there isn't a way for you to access it. – mmhan Sep 19 '11 at 16:48
-
Does anyone know if Flash is so cool to find it? – Dan Apr 04 '13 at 11:31
3 Answers
The library datejs can do things like that. Also check this discussion
-
1No, datejs cannot give you the locale-specific first day of the week. – Ville Laurikari May 16 '17 at 07:26
I could not find any out-of-the-box solutions for you, but if you want to persist this endeavor you may find the following ideas useful:
You can detect the locale of the browser using one of the following functions in JavaScript:
http://www.techrepublic.com/article/detect-foreign-language-support-using-javascript/5069931
Then, you have to map the locale (language) to the preferred start day of the week. You could create JavaScript arrays in a separate source file using a local (server side) scripting language with I18N support:
How to determine the first day of week in python
(shows Java and Python example)
As an alternative, YUI, a JavaScript framework, provides a rich internationalization framework. Although it may be a bit heavy for your needs, and I couldn't find a function that would provide you the first day of the week, it may come in handy for your application:
http://yuilibrary.com/yui/docs/intl/
You can add the first day of the week attribute to the resource bundles yourself (or log a ticket with tem). For an example of the French resource bundle:
http://yui.yahooapis.com/combo?3.3.0/build/datatype/lang/datatype-date_fr-FR.js
There also is a jQuery plugin for i18n support:
http://plugins.jquery.com/project/jquery_i18n_properties
But it looks like that it doesn't come with usable resource bundles.

- 1
- 1
The only sure way is to ask the visitor.
<fieldset id="firstdayofweekFieldset">
<legend>First Day Of the Week</legend>
<label>Sunday <input type="radio" name="firstdayofweek" value="0" checked></label>
<label>Monday <input type="radio" name="firstdayofweek" value="1" ></label>
</fieldset>

- 102,654
- 32
- 106
- 127