Intl.DurationFormat
Baseline
2025
Newly available
Since March 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Intl.DurationFormat ãªãã¸ã§ã¯ãã«ãããè¨èªã«ä¾åããçµéæéã®æ¸å¼åãã§ãã¾ãã
ã³ã³ã¹ãã©ã¯ã¿ã¼
Intl.DurationFormat()-
æ°ãã
Intl.DurationFormatãªãã¸ã§ã¯ãã使ãã¾ãã
éçã¡ã½ãã
Intl.DurationFormat.supportedLocalesOf()-
æå®ããããã±ã¼ã«ã®ãã¡ãã©ã³ã¿ã¤ã ã®æ¢å®ã®ãã±ã¼ã«ã§ä»£æ¿ãããã¨ãªã対å¿ãã¦ãããã®ãé åã¨ãã¦è¿ãã¾ãã
ã¤ã³ã¹ã¿ã³ã¹ããããã£
ãããã®ããããã£ã¯ Intl.DurationFormat.prototype ã§å®ç¾©ããã¦ããããã¹ã¦ã® Intl.DurationFormat ã¤ã³ã¹ã¿ã³ã¹ã§å
±æããã¾ãã
Intl.DurationFormat.prototype.constructor-
ã¤ã³ã¹ã¿ã³ã¹ãªãã¸ã§ã¯ãã使ããã³ã³ã¹ãã©ã¯ã¿ã¼é¢æ°ã
Intl.DurationFormatã¤ã³ã¹ã¿ã³ã¹ã®å ´åãåæå¤ã¯Intl.DurationFormatã³ã³ã¹ãã©ã¯ã¿ã¼ã§ãã Intl.DurationFormat.prototype[Symbol.toStringTag]-
[Symbol.toStringTag]ããããã£ã®åæå¤ã¯ãæåå"Intl.DurationFormat"ã§ãããã®ããããã£ã¯ãObject.prototype.toString()ã§ä½¿ç¨ããã¾ãã
ã¤ã³ã¹ã¿ã³ã¹ã¡ã½ãã
Intl.DurationFormat.prototype.format()-
ãã®
DurationFormatãªãã¸ã§ã¯ãã®ãã±ã¼ã«ããã³æ¸å¼è¨å®ãªãã·ã§ã³ã«å¾ã£ã¦çµéæéãæ¸å¼åããã²ãã¿ã¼é¢æ°ã§ãã Intl.DurationFormat.prototype.formatToParts()-
æ¸å¼åãããçµéæéãåé¨åã§è¡¨ããªãã¸ã§ã¯ãã®é å (
Array) ãè¿ãã¾ãã Intl.DurationFormat.prototype.resolvedOptions()-
ãªãã¸ã§ã¯ãã®åæåæã«è¨ç®ããããã±ã¼ã«ããã³æ¸å¼åãªãã·ã§ã³ãåæ ããããããã£ãæã¤æ°ãããªãã¸ã§ã¯ããè¿ãã¾ãã
ä¾
>Intl.DurationFormat ã®ä½¿ç¨
以ä¸ã®ä¾ã¯ãIntl.DurationFormat ãªãã¸ã§ã¯ãã使ç¨ãã¦ããã¾ãã¾ãªãã±ã¼ã«ããã³ã¹ã¿ã¤ã«ã§åçæéãªãã¸ã§ã¯ããæ¸å¼åããæ¹æ³ã示ãã¦ãã¾ãã
const duration = {
hours: 1,
minutes: 46,
seconds: 40,
};
// ã¹ã¿ã¤ã«ã "long" ã«ããã±ã¼ã«ã "fr-FR" ã«è¨å®
new Intl.DurationFormat("fr-FR", { style: "long" }).format(duration);
// "1 heure, 46 minutes et 40 secondes"
// ã¹ã¿ã¤ã«ã "short" ã«ããã±ã¼ã«ã "en" ã«è¨å®
new Intl.DurationFormat("en", { style: "short" }).format(duration);
// "1 hr, 46 min and 40 sec"
// ã¹ã¿ã¤ã«ã "narrow" ã«ããã±ã¼ã«ã "pt" ã«è¨å®
new Intl.DurationFormat("pt", { style: "narrow" }).format(duration);
// "1h 46min 40s"
仿§æ¸
| Specification |
|---|
| Intl.DurationFormat> # durationformat-objects> |