Intl.Locale.prototype.getHourCycles()
Intl.Locale
实例的 getHourCycles()
方法返回此区域设置的一个或多个唯一小时周期标识符的列表。
¥The getHourCycles()
method of Intl.Locale
instances returns a list of one or more unique hour cycle identifiers for this locale.
注意:在某些浏览器的某些版本中,此方法被实现为名为
hourCycles
的访问器属性。但是,由于每次访问时都会返回一个新数组,因此现在将其实现为一种方法,以防止出现locale.hourCycles === locale.hourCycles
返回false
的情况。检查 浏览器兼容性表 了解详细信息。¥Note: In some versions of some browsers, this method was implemented as an accessor property called
hourCycles
. However, because it returns a new array on each access, it is now implemented as a method to prevent the situation oflocale.hourCycles === locale.hourCycles
returningfalse
. Check the browser compatibility table for details.
语法
参数
返回值
¥Return value
表示 Locale
常用的所有小时周期类型的字符串数组,按优先级降序排序。如果 Locale
已有 hourCycle
,则返回的数组包含该单个值。
¥An array of strings representing all hour cycle types commonly used for the Locale
, sorted in descending preference. If the Locale
already has an hourCycle
, then the returned array contains that single value.
以下是受支持的小时周期类型的列表。
¥Below is a list of supported hour cycle types.
支持的小时周期类型
示例
获取支持的小时周期
¥Obtaining supported hour cycles
如果 Locale
对象还没有 hourCycle
,则 getHourCycles()
列出给定 Locale
的所有常用小时周期标识符。有关显式设置 hourCycle
的示例,请参阅 hourCycle
个例子。
¥If the Locale
object doesn't have a hourCycle
already, getHourCycles()
lists all commonly-used hour cycle identifiers for the given Locale
. For examples of explicitly setting a hourCycle
, see hourCycle
examples.
const arEG = new Intl.Locale("ar-EG");
console.log(arEG.getHourCycles()); // ["h12"]
const jaJP = new Intl.Locale("ja-JP");
console.log(jaJP.getHourCycles()); // ["h23"]
规范
Specification |
---|
Intl Locale Info Proposal # sec-Intl.Locale.prototype.getHourCycles |
浏览器兼容性
BCD tables only load in the browser
也可以看看
¥See also
Intl.Locale
Intl.Locale.prototype.hourCycle
- Unicode 区域设置数据标记语言规范中的 Unicode 小时周期标识符