Baseline 2025
Newly available
Das Intl.DurationFormat
-Objekt ermöglicht die sprachsensitive Formatierung von Zeitdauern.
Intl.DurationFormat()
Erstellt ein neues Intl.DurationFormat
-Objekt.
Intl.DurationFormat.supportedLocalesOf()
Gibt ein Array zurück, das die der angegebenen Lokalisierungen enthält, die unterstützt werden, ohne auf die Standard-Lokalisierung der Laufzeitumgebung zurückgreifen zu müssen.
Diese Eigenschaften sind auf Intl.DurationFormat.prototype
definiert und werden von allen Intl.DurationFormat
-Instanzen geteilt.
Intl.DurationFormat.prototype.constructor
Die Konstruktorfunktion, die das Instanzobjekt erstellt hat. Für Intl.DurationFormat
-Instanzen ist der Anfangswert der Intl.DurationFormat
-Konstruktor.
Intl.DurationFormat.prototype[Symbol.toStringTag]
Der Anfangswert der [Symbol.toStringTag]
-Eigenschaft ist der String "Intl.DurationFormat"
. Diese Eigenschaft wird in Object.prototype.toString()
verwendet.
Intl.DurationFormat.prototype.format()
Getter-Funktion, die eine Dauer gemäà der Lokalisierung und den Formatierungsoptionen dieses DurationFormat
-Objekts formatiert.
Intl.DurationFormat.prototype.formatToParts()
Gibt ein Array
von Objekten zurück, die die formatierte Dauer in Teilen darstellen.
Intl.DurationFormat.prototype.resolvedOptions()
Gibt ein neues Objekt mit Eigenschaften zurück, die die bei der Initialisierung des Objekts ermittelten Lokalisierungs- und Formatierungsoptionen widerspiegeln.
Die folgenden Beispiele zeigen, wie Sie das Intl.DurationFormat
-Objekt verwenden, um ein Dauerobjekt mit verschiedenen Lokalisierungen und Stilen zu formatieren.
const duration = {
hours: 1,
minutes: 46,
seconds: 40,
};
// With style set to "long" and locale "fr-FR"
new Intl.DurationFormat("fr-FR", { style: "long" }).format(duration);
// "1 heure, 46 minutes et 40 secondes"
// With style set to "short" and locale "en"
new Intl.DurationFormat("en", { style: "short" }).format(duration);
// "1 hr, 46 min and 40 sec"
// With style set to "narrow" and locale "pt"
new Intl.DurationFormat("pt", { style: "narrow" }).format(duration);
// "1h 46min 40s"
Spezifikationen Browser-Kompatibilität Siehe auch MDN-Feedback-Box War diese Ãbersetzung hilfreich?
Diese Seite wurde automatisch aus dem Englischen übersetzt.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4