Client's first day of the week
Asked Answered
V

3

12

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.

Vu answered 19/9, 2011 at 16:17 Comment(4)
Is that supposed to be some settings that you set on OS? Never heard of such a setting before.Aeniah
yep. I don't know bout others but in Windows there is oneVu
If google isn't doing it for google calendar, I suppose there isn't a way for you to access it.Aeniah
Does anyone know if Flash is so cool to find it?Emetine
A
1

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.

Alcine answered 19/9, 2011 at 16:17 Comment(0)
E
1

The library datejs can do things like that. Also check this discussion

Emetine answered 4/4, 2013 at 11:23 Comment(1)
No, datejs cannot give you the locale-specific first day of the week.Quag
T
-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>
Tanked answered 19/9, 2011 at 16:50 Comment(1)
OMG, not in the XXI century!Emetine

© 2022 - 2024 — McMap. All rights reserved.