Provides locale specific properties and formatted data.
The Locale object may only be created via the global locale() function. It cannot be created directly.
The global locale() function returns a JS Locale object representing the locale with the specified name, which has the format language[_territory][.codeset][@modifier] or C.
Locale supports the concept of a default locale, which is determined from the system's locale settings at application startup. If no parameter is passed to locale() the default locale object is returned.
The Locale object provides a number of functions and properties providing data for the specified locale.
Locale.LongFormat The long version of day and month names; for example, returning "January" as a month name.
Locale.ShortFormat The short version of day and month names; for example, returning "Jan" as a month name.
Locale.NarrowFormat A special version of day and month names for use when space is limited; for example, returning "J" as a month name. Note that the narrow format might contain the same text for different months and days or it can even be an empty string if the locale doesn't support narrow names, so you should avoid using it for date formatting. Also, for the system locale this format is the same as ShortFormat.
Date format specifiers
Besides the fixed format types listed above, a format string passed to the various Date formatting functions (Date.toLocaleString() and family) specifies a format string, it should use the following expressions to specify the date:
Expression
Output
d
the day as number without a leading zero (1 to 31)
dd
the day as number with a leading zero (01 to 31)
ddd
the abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses QDate::shortDayName().
dddd
the long localized day name (e.g. 'Monday' to 'Qt::Sunday'). Uses QDate::longDayName().
M
the month as number without a leading zero (1-12)
MM
the month as number with a leading zero (01-12)
MMM
the abbreviated localized month name (e.g. 'Jan' to 'Dec'). Uses QDate::shortMonthName().
MMMM
the long localized month name (e.g. 'January' to 'December'). Uses QDate::longMonthName().
yy
the year as two digit number (00-99)
yyyy
the year as four digit number
In addition the following expressions can be used to specify the time:
Expression
Output
h
the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)
hh
the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)
m
the minute without a leading zero (0 to 59)
mm
the minute with a leading zero (00 to 59)
s
the second without a leading zero (0 to 59)
ss
the second with a leading zero (00 to 59)
z
the milliseconds without leading zeroes (0 to 999)
zzz
the milliseconds with leading zeroes (000 to 999)
AP
use AM/PM display. AP will be replaced by either "AM" or "PM".
ap
use am/pm display. ap will be replaced by either "am" or "pm".
t
include a time-zone indicator.
All other input characters will be ignored. Any sequence of characters that are enclosed in single quotes will be treated as text and not be used as an expression. Two consecutive single quotes (‘’'`) are replaced by a single quote in the output.
For example, if the following date/time value was specified:
This documentation is originally from the Qt library's QQmlLocale class, used under the GNU Free Documentation License.
Locale's data is based on Common Locale Data Repository v1.8.1.
Copyright (c) 1991 by AT&T.
Permission to use, copy, modify, and distribute this software for any
purpose without fee is hereby granted, provided that this entire notice
is included in all copies of any software which is or includes a copy
or modification of this software and in all copies of the supporting
documentation for such software.
THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
This product includes software developed by the University of
California, Berkeley and its contributors.
Holds the language and country of this locale as a string of the form "language_country", where language is a lowercase, two-letter ISO 639 language code, and country is an uppercase, two- or three-letter ISO 3166 country code.
Returns the localized name of the day (where 0 represents Sunday, 1 represents Monday and so on), in the optional Locale String Format Types specified by type.
Returns the localized name of the day (where 0 represents Sunday, 1 represents Monday and so on) that is used as a standalone text, in the Locale String Format Types specified by type.
If the locale information does not specify the standalone day name then return value is the same as in dayName().