globalization.getFirstDayOfWeek

Returns the first day of the week according to the client's user preferences and calendar.

navigator.globalization.getFirstDayOfWeek(successCB, errorCB);

Description

The days of the week are numbered starting from 1 where 1 is considered to be Sunday. It returns the day to the successCB callback with a properties object as a parameter. That object should have a value property with a Number value.

If there is an error obtaining the pattern, then the errorCB callback is invoked with a GlobalizationError object as a parameter. The expected code for this error is GlobalizationError.UNKNOWN_ERROR.

Supported Platforms

  • Android
  • BlackBerry WebWorks (OS 5.0 and higher)
  • iPhone

Quick Example

In the case when the browser is set to the en_US locale, this should display a popup dialog with text similar to "day: 1".

navigator.globalization.getFirstDayOfWeek(
  function (day) {alert('day: ' + day.value + '\n');},
  function () {alert('Error getting day\n');}
);

Full Example

<!DOCTYPE HTML>
<html>
  <head>
    <title>Cordova</title>
    <script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"></script>
    <script type="text/javascript" charset="utf-8">
                  
    function checkFirstDay() {
      navigator.globalization.getFirstDayOfWeek(
        function (day) {alert('day: ' + day.value + '\n');},
        function () {alert('Error getting day\n');}
      );
    }
    
    </script>
  </head>
  <body>
    <button onclick="checkFirstDay()">Click for first day of week</button>
  </body>
</html>