From 844f5103992238c0c23203286dad16a466e89c97 Mon Sep 17 00:00:00 2001 From: julieng Date: Tue, 3 Aug 2021 08:03:09 +0200 Subject: move *.html to *.md --- .../global_objects/date/toisostring/index.html | 104 --------------------- .../global_objects/date/toisostring/index.md | 104 +++++++++++++++++++++ 2 files changed, 104 insertions(+), 104 deletions(-) delete mode 100644 files/fr/web/javascript/reference/global_objects/date/toisostring/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/date/toisostring/index.md (limited to 'files/fr/web/javascript/reference/global_objects/date/toisostring') diff --git a/files/fr/web/javascript/reference/global_objects/date/toisostring/index.html b/files/fr/web/javascript/reference/global_objects/date/toisostring/index.html deleted file mode 100644 index 102c8dfb19..0000000000 --- a/files/fr/web/javascript/reference/global_objects/date/toisostring/index.html +++ /dev/null @@ -1,104 +0,0 @@ ---- -title: Date.prototype.toISOString() -slug: Web/JavaScript/Reference/Global_Objects/Date/toISOString -tags: - - Date - - JavaScript - - Méthode - - Prototype - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Date/toISOString -original_slug: Web/JavaScript/Reference/Objets_globaux/Date/toISOString ---- -
{{JSRef}}
- -

La méthode toISOString() renvoie une chaîne de caractères au format ISO (ISO 8601 Extended Format), qui peut être décrite de cette façon : YYYY-MM-DDTHH:mm:ss.sssZ (toujours longue de 24 caractères) ou de cette façon ±YYYYYY-MM-DDTHH:mm:ss.sssZ (27 caractères). Le fuseau horaire est toujours UTC, comme l'indique le suffixe « Z » (pour zéro décalage avec UTC).

- -
{{EmbedInteractiveExample("pages/js/date-toisostring.html")}}
- -

Syntaxe

- -
dateObj.toISOString()
- -

Valeur de retour

- -

Une chaîne de caractères représentant la date indiquée au format ISO 8601 selon le temps universel.

- -

Exemples

- -

Utiliser toISOString()

- -
var aujourdhui = new Date("05 October 2011 14:48 UTC");
-
-console.log(aujourdhui.toISOString()); // Renvoie "2011-10-05T14:48:00.000Z"
-
- -

L'exemple ci-dessus analyse une chaîne de caractères non-standard, qui peut donc être incorrectement intérprété par des navigateurs n'utilisant pas Gecko.

- -

Prothèse d'émulation (polyfill)

- -

Cette méthode fut standardisée avec la cinquième édition d'ECMAScript. Afin d'utiliser cette méthode avec les moteurs qui n'en disposent pas nativement, on pourra utiliser ce fragment de code :

- -
if ( !Date.prototype.toISOString ) {
-  ( function() {
-
-    function pad(number) {
-      if ( number < 10 ) {
-        return '0' + number;
-      }
-      return number;
-    }
-
-    Date.prototype.toISOString = function() {
-      return this.getUTCFullYear() +
-        '-' + pad( this.getUTCMonth() + 1 ) +
-        '-' + pad( this.getUTCDate() ) +
-        'T' + pad( this.getUTCHours() ) +
-        ':' + pad( this.getUTCMinutes() ) +
-        ':' + pad( this.getUTCSeconds() ) +
-        '.' + (this.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) +
-        'Z';
-    };
-
-  }() );
-}
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES5.1', '#sec-15.9.5.43', 'Date.prototype.toISOString')}}{{Spec2('ES5.1')}}Définition initiale. Implémentée avec JavaScript 1.8.
{{SpecName('ES6', '#sec-date.prototype.toisostring', 'Date.prototype.toISOString')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-date.prototype.toisostring', 'Date.prototype.toISOString')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

{{Compat("javascript.builtins.Date.toISOString")}}

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/date/toisostring/index.md b/files/fr/web/javascript/reference/global_objects/date/toisostring/index.md new file mode 100644 index 0000000000..102c8dfb19 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/date/toisostring/index.md @@ -0,0 +1,104 @@ +--- +title: Date.prototype.toISOString() +slug: Web/JavaScript/Reference/Global_Objects/Date/toISOString +tags: + - Date + - JavaScript + - Méthode + - Prototype + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Date/toISOString +original_slug: Web/JavaScript/Reference/Objets_globaux/Date/toISOString +--- +
{{JSRef}}
+ +

La méthode toISOString() renvoie une chaîne de caractères au format ISO (ISO 8601 Extended Format), qui peut être décrite de cette façon : YYYY-MM-DDTHH:mm:ss.sssZ (toujours longue de 24 caractères) ou de cette façon ±YYYYYY-MM-DDTHH:mm:ss.sssZ (27 caractères). Le fuseau horaire est toujours UTC, comme l'indique le suffixe « Z » (pour zéro décalage avec UTC).

+ +
{{EmbedInteractiveExample("pages/js/date-toisostring.html")}}
+ +

Syntaxe

+ +
dateObj.toISOString()
+ +

Valeur de retour

+ +

Une chaîne de caractères représentant la date indiquée au format ISO 8601 selon le temps universel.

+ +

Exemples

+ +

Utiliser toISOString()

+ +
var aujourdhui = new Date("05 October 2011 14:48 UTC");
+
+console.log(aujourdhui.toISOString()); // Renvoie "2011-10-05T14:48:00.000Z"
+
+ +

L'exemple ci-dessus analyse une chaîne de caractères non-standard, qui peut donc être incorrectement intérprété par des navigateurs n'utilisant pas Gecko.

+ +

Prothèse d'émulation (polyfill)

+ +

Cette méthode fut standardisée avec la cinquième édition d'ECMAScript. Afin d'utiliser cette méthode avec les moteurs qui n'en disposent pas nativement, on pourra utiliser ce fragment de code :

+ +
if ( !Date.prototype.toISOString ) {
+  ( function() {
+
+    function pad(number) {
+      if ( number < 10 ) {
+        return '0' + number;
+      }
+      return number;
+    }
+
+    Date.prototype.toISOString = function() {
+      return this.getUTCFullYear() +
+        '-' + pad( this.getUTCMonth() + 1 ) +
+        '-' + pad( this.getUTCDate() ) +
+        'T' + pad( this.getUTCHours() ) +
+        ':' + pad( this.getUTCMinutes() ) +
+        ':' + pad( this.getUTCSeconds() ) +
+        '.' + (this.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) +
+        'Z';
+    };
+
+  }() );
+}
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES5.1', '#sec-15.9.5.43', 'Date.prototype.toISOString')}}{{Spec2('ES5.1')}}Définition initiale. Implémentée avec JavaScript 1.8.
{{SpecName('ES6', '#sec-date.prototype.toisostring', 'Date.prototype.toISOString')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-date.prototype.toisostring', 'Date.prototype.toISOString')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

{{Compat("javascript.builtins.Date.toISOString")}}

+ +

Voir aussi

+ + -- cgit v1.2.3-54-g00ecf