UNB/ CS/ David Bremner/ teaching/ cs2613/ books/ mdn/ Reference/ Global Objects/ Intl/ Locale/ Intl.Locale.prototype.getWeekInfo()

The getWeekInfo() method of Intl.Locale instances returns a weekInfo object with the properties firstDay, weekend and minimalDays for this locale.

Note: In some versions of some browsers, this method was implemented as an accessor property called weekInfo. However, because it returns a new object on each access, it is now implemented as a method to prevent the situation of locale.weekInfo === locale.weekInfo returning false. Check the browser compatibility table for details.

Syntax

getWeekInfo()

Parameters

None.

Return value

An object representing week information associated with the Locale data specified in UTS 35's Week Elements. It has the following properties:

Examples

Obtaining the Week Information

Return the week information for a given Locale.

const he = new Intl.Locale("he");
console.log(he.getWeekInfo()); // { firstDay: 7, weekend: [5, 6], minimalDays: 1 }

const af = new Intl.Locale("af");
console.log(af.getWeekInfo()); // { firstDay: 7, weekend: [6, 7], minimalDays: 1 }

const enGB = new Intl.Locale("en-GB");
console.log(enGB.getWeekInfo()); // { firstDay: 1, weekend: [6, 7], minimalDays: 4 }

const msBN = new Intl.Locale("ms-BN");
console.log(msBN.getWeekInfo()); // { firstDay: 7, weekend: [5, 7], minimalDays: 1 }
// Brunei weekend is Friday and Sunday but not Saturday

Specifications

Browser compatibility

See also