diff options
author | JF Tregor <jeanfrancois.tregor@gmail.com> | 2021-03-22 16:15:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-22 16:15:42 +0100 |
commit | dd3abb74219a174743cc4dbd0f9f8b8d2362d7c4 (patch) | |
tree | 8e5bf0022ee1dbbf0ff68a42d7a1a089b0c430eb | |
parent | 08c83f6e3a1e5656d18edc1b6fcaffa89b16fd4f (diff) | |
download | translated-content-dd3abb74219a174743cc4dbd0f9f8b8d2362d7c4.tar.gz translated-content-dd3abb74219a174743cc4dbd0f9f8b8d2362d7c4.tar.bz2 translated-content-dd3abb74219a174743cc4dbd0f9f8b8d2362d7c4.zip |
fix typo in Date code sample (#283)
just to avoid 'ReferenceError' for unknown "today" and "msPerDay"...
-rw-r--r-- | files/fr/web/javascript/guide/numbers_and_dates/index.html | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/files/fr/web/javascript/guide/numbers_and_dates/index.html b/files/fr/web/javascript/guide/numbers_and_dates/index.html index 642380d4b6..7cd261dfda 100644 --- a/files/fr/web/javascript/guide/numbers_and_dates/index.html +++ b/files/fr/web/javascript/guide/numbers_and_dates/index.html @@ -347,7 +347,7 @@ finAnnée<span class="punctuation token">.</span><span class="function token">se <span class="keyword token">var</span> msParJour <span class="operator token">=</span> <span class="number token">24</span> <span class="operator token">*</span> <span class="number token">60</span> <span class="operator token">*</span> <span class="number token">60</span> <span class="operator token">*</span> <span class="number token">1000</span><span class="punctuation token">;</span> <span class="comment token">// On renvoie le nombre de jours restants dans l'année</span> -<span class="keyword token">var</span> joursRestants <span class="operator token">=</span> <span class="punctuation token">(</span>finAnnée<span class="punctuation token">.</span><span class="function token">getTime</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="operator token">-</span> today<span class="punctuation token">.</span><span class="function token">getTime</span><span class="punctuation token">(</span><span class="punctuation token">)</span><span class="punctuation token">)</span> <span class="operator token">/</span> msPerDay<span class="punctuation token">;</span> +<span class="keyword token">var</span> joursRestants <span class="operator token">=</span> <span class="punctuation token">(</span>finAnnée<span class="punctuation token">.</span><span class="function token">getTime</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="operator token">-</span> aujourdhui<span class="punctuation token">.</span><span class="function token">getTime</span><span class="punctuation token">(</span><span class="punctuation token">)</span><span class="punctuation token">)</span> <span class="operator token">/</span> msParJour<span class="punctuation token">;</span> joursRestants <span class="operator token">=</span> Math<span class="punctuation token">.</span><span class="function token">round</span><span class="punctuation token">(</span>joursRestants<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> <p>Cet exemple crée un objet <code>Date</code> nommé <code>aujourdhui</code> qui contient la date du jour. On crée ensuite un objet <code>Date</code> nommé <code>finAnnée</code> pour lequel on définit ensuite l'année avec l'année courante. Après, on calcule le nombre de millisecondes qui s'écoulent dans une journée. Enfin, on calcule le nombre de jours entre <code>aujourdhui</code> et <code>finAnnée</code> en utilisant <code>getTime</code> puis on arrondit le tout pour avoir un nombre de jours.</p> |