CultureInfo Constructor

Syntax

CultureInfo(settings);

Parameters

settings. JSON object that contains values of class properties.

Description

The CultureInfo constructor creates an instance of the CultureInfo class.

Example

To execute the example, add a link to PP.js scenario file to HTML page. Create a new object of the CultureInfo class, that specifies culture; define date and get corresponding names for week day, month, quarter and half-year:

// Determine new regional settings
var cultureInfo = new PP.CultureInfo();
cultureInfo.CultureName = PP.CultureNames.ru;
cultureInfo.DisplayName = "Russian"; // Understandable displayed language name
cultureInfo.IsSundayFirst = True; // Sunday is the first week day
cultureInfo.WEEKMS = 1000 * 60 * 60 * 24 * 7; // Number of milliseconds in the week
cultureInfo.LCID = 1049; //Locale code in LCID
// Text in visual components will be placed to the right edge
cultureInfo.IsRTL = False;
// Specify the path to the root folder containing resources files         
PP.resourceManager.setRootResourcesFolder("../resources/");
// Apply regional settings
PP.setCurrentCulture(cultureInfo);
// Determine date
var date = new Date(2013, 8, 25);
console.log("Specified date: " + date.toString());
// Set full names of week days
cultureInfo.DayNames = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
// Determine a week day
var day = cultureInfo.ShortDayNames[date.getDay() - 1];
console.log("Week day: " + day);
// Set full names of months
cultureInfo.MonthNames = ["January", "February", "March", "April", "May", "June",
        "July", "August", "September", "October", "November", "December"
];
// Set short names of months		
cultureInfo.ShortMonthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
];
// Determine month for the specified date
var month = date.getMonth();
console.log("Month: " + cultureInfo.MonthNames[month]);
console.log("Short month name: " + cultureInfo.ShortMonthNames[month]);
// Set quarter names
cultureInfo.QuarterNames = ["I", "II", "III", "IV"];
// Determine quarter for the specified date
var quarter = ((month + 1) / 4 | 0);
console.log("Year quarter: " + cultureInfo.QuarterNames[quarter]);
// Set names of half-years
cultureInfo.HalfYearNames = ["I", "II"];
// Determine half-year for the specified date
var halfYear = (month - 1) / 6 | 0;
console.log("Half-year number: " + cultureInfo.HalfYearNames[halfYear]);

After the example a new CultureInfo object is created. This object sets Russian language and its regional parameters. Corresponding week day, month, quarter and half-year names are received for the date Septermer 25, 2013:

Specified date: Wed Sep 25 2017 00:00:00 GMT+0400 (Moscow time zone (winter))
Week day: Wednesday
Month: September
Short month name: Sep
Quarter: III
Half-year: II

See also:

CultureInfo