diff options
Diffstat (limited to 'files/ar/web/javascript/reference/global_objects/date/parse/index.html')
-rw-r--r-- | files/ar/web/javascript/reference/global_objects/date/parse/index.html | 182 |
1 files changed, 0 insertions, 182 deletions
diff --git a/files/ar/web/javascript/reference/global_objects/date/parse/index.html b/files/ar/web/javascript/reference/global_objects/date/parse/index.html deleted file mode 100644 index 133b751cd6..0000000000 --- a/files/ar/web/javascript/reference/global_objects/date/parse/index.html +++ /dev/null @@ -1,182 +0,0 @@ ---- -title: Date.parse() | دالة تحليل الوقت -slug: Web/JavaScript/Reference/Global_Objects/Date/parse -tags: - - Date - - التاريخ - - جافاسكربت - - طريقة - - مرجع -translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse ---- -<div>{{JSRef}}</div> - -<p>تقوم دالة <code>Date.parse()</code> بتوزيع سلسلة من التاريخ، وإرجاع قيمتها إلي مللي ثانية من بداية تاريخ (1 يناير, 1970, 00:00:00 UTC) إلي التاريخ المحدد داخل الأقواس مثل <font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.5);">Date.parse("التاريخ")</span></font> أو NaN (ليس رقم) إذا كانت السلسلة غير معترف بها (غير صحيحة)، أو في بعض الحالات التي يكون فيها قيم التاريخ غير شرعية (مكتوبة بشكل خاطيء). علي سبيل المثال (2015-02-31).</p> - -<p>It is not recommended to use <code>Date.parse</code> as until ES5, parsing of strings was entirely implementation dependent. There are still many differences in how different hosts parse date strings, therefore date strings should be manually parsed (a library can help if many different formats are to be accommodated).</p> - -<div>{{EmbedInteractiveExample("pages/js/date-parse.html")}}</div> - - - -<h2 id="بنية_الجملة">بنية الجملة</h2> - -<p>استدعاء مباشر:</p> - -<pre class="syntaxbox">Date.parse(<var>dateString</var>)</pre> - -<p>استدعاء ضمني:</p> - -<pre class="syntaxbox">new Date(<var>dateString</var>)</pre> - -<h3 id="المعاملات">المعاملات</h3> - -<dl> - <dt><code>dateString</code></dt> - <dd>النص يمثل <a href="http://tools.ietf.org/html/rfc2822#section-3.3">RFC2822</a> أو (a variant of) تاريخ <a href="https://ar.wikipedia.org/wiki/%D8%A7%D9%8A%D8%B2%D9%88_8601">ISO 8601</a> (قد يتم استخدام تنسيقات أخري، ولكن ربما قد تكون النتائج غير متوقعة).</dd> -</dl> - -<h3 id="القيمة_الراجعة">القيمة الراجعة</h3> - -<p>A number representing the milliseconds elapsed since January 1, 1970, 00:00:00 UTC and the date obtained by parsing the given string representation of a date. If the argument doesn't represent a valid date, {{jsxref("NaN")}} is returned.</p> - -<h2 id="الوصف">الوصف</h2> - -<p>تقوم دالة <code>parse()</code> بأخذ سلسلة التاريخ مثل ("Des 25, 1995") وتقوم بإرجاع القيمة إلي المللي ثانية منذ بداية احتساب الوقت وهو الأول من يناير عام 1970 الساعة الثانية عشر منتصف الليل تماماً (First of January 1970 00:00:00) بتوقيت UTC، حتي الوقت التي قمت بتحديده. وهذه الدالة مفيدة لتعيين قيمة التاريخ استناداً الي قيمة السلسلة، علي سبيل المثال الدمج مع طريقة {{jsxref("Date.prototype.setTime()", "setTime()")}} و {{jsxref("Global_Objects/Date", "Date")}} .</p> - -<p>Given a string representing a time, <code>parse()</code> returns the time value. It accepts the RFC2822 / IETF date syntax (<a href="http://tools.ietf.org/html/rfc2822#section-3.3">RFC2822 Section 3.3</a>), e.g. <code>"Mon, 25 Dec 1995 13:30:00 GMT"</code>. It understands the continental US time zone abbreviations, but for general use, use a time zone offset, for example, <code>"Mon, 25 Dec 1995 13:30:00 +0430"</code> (4 hours, 30 minutes east of the Greenwich meridian).</p> - -<p>GMT and UTC are considered equivalent. The local time zone is used to interpret arguments in <a href="http://tools.ietf.org/html/rfc2822#section-3.3">RFC2822 Section 3.3</a> format that do not contain time zone information.</p> - -<p>Because of the variances in parsing of date strings, it is recommended to always manually parse strings as results are inconsistent, especially across different ECMAScript implementations where strings like <code>"2015-10-12 12:00:00"</code> may be parsed to as <code>NaN</code>, UTC or local timezone.</p> - -<h3 dir="ltr" id="ECMAScript_5_دعم_تنسيق_ISO-8601">ECMAScript 5 دعم تنسيق ISO-8601</h3> - -<p>The date time string may be in a simplified <a href="http://www.w3.org/TR/NOTE-datetime">ISO 8601</a> format. For example, <code>"2011-10-10"</code> (just date) or <code>"2011-10-10T14:48:00"</code> (date and time) can be passed and parsed. Where the string is ISO 8601 date only, the UTC time zone is used to interpret arguments. If the string is date and time in <a href="http://www.w3.org/TR/NOTE-datetime">ISO 8601</a> format, it will be treated as local.</p> - -<p>While time zone specifiers are used during date string parsing to interpret the argument, the value returned is always the number of milliseconds between January 1, 1970 00:00:00 UTC and the point in time represented by the argument or <code>NaN</code>.</p> - -<p>Because <code>parse()</code> is a static method of {{jsxref("Date")}}, it is called as <code>Date.parse()</code> rather than as a method of a {{jsxref("Date")}} instance.</p> - -<h3 id="الاختلافات_في_المنطقة_الزمنية_المفترضة">الاختلافات في المنطقة الزمنية المفترضة</h3> - -<p>Given a date string of <code>"March 7, 2014"</code>, <code>parse()</code> assumes a local time zone, but given an ISO format such as <code>"2014-03-07"</code> it will assume a time zone of UTC (ES5 and ECMAScript 2015). Therefore {{jsxref("Date")}} objects produced using those strings may represent different moments in time depending on the version of ECMAScript supported unless the system is set with a local time zone of UTC. This means that two date strings that appear equivalent may result in two different values depending on the format of the string that is being converted.</p> - -<h3 id="Fall-back_to_implementation-specific_date_formats">Fall-back to implementation-specific date formats</h3> - -<p>The ECMAScript specification states: If the String does not conform to the standard format the function may fall back to any implementation–specific heuristics or implementation–specific parsing algorithm. Unrecognizable strings or dates containing illegal element values in ISO formatted strings shall cause <code>Date.parse()</code> to return {{jsxref("NaN")}}.</p> - -<p>However, invalid values in date strings not recognized as simplified ISO format as defined by ECMA-262 may or may not result in {{jsxref("NaN")}}, depending on the browser and values provided, e.g.:</p> - -<pre class="brush: js" dir="rtl">// سلسلة ليست أيزو مع قيم تاريخ صالحة -new Date('23/25/2014'); -</pre> - -<p>will be treated as a local date of 25 November, 2015 in Firefox 30 and an invalid date in Safari 7. However, if the string is recognized as an ISO format string and it contains invalid values, it will return {{jsxref("NaN")}} in all browsers compliant with ES5 and later:</p> - -<pre class="brush: js" dir="rtl">// سلسلة أيزو مع قيمة غير صالحة -new Date('2014-25-23').toISOString(); -// يُعيد "RangeError: invalid date" في جميع المتصفحات المتوافقة مع es5 -</pre> - -<p>SpiderMonkey's implementation-specific heuristic can be found in <a href="http://mxr.mozilla.org/mozilla-central/source/js/src/jsdate.cpp?rev=64553c483cd1#889"><code>jsdate.cpp</code></a>. The string <code>"10 06 2014"</code> is an example of a non–conforming ISO format and thus falls back to a custom routine. See also this <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1023155#c6">rough outline</a> on how the parsing works.</p> - -<pre class="brush: js">new Date('10 06 2014'); -</pre> - -<p>will be treated as a local date of 6 October, 2014 and not 10 June, 2014. Other examples:</p> - -<pre class="brush: js">new Date('foo-bar 2014').toString(); -// يُعيد: "Invalid Date" *تاريخ غير صالح* - -Date.parse('foo-bar 2014'); -// يُعيد: NaN *ليس رقم* -</pre> - -<h2 id="أمثلة">أمثلة</h2> - -<h3 id="استخدام_Date.parse()">استخدام <code>Date.parse()</code></h3> - -<p>إذا كان <code>IPOdate</code> هو كائن {{jsxref("Date")}} موجود، فيمكن تعيينه إلي 9 أغسطس، 1995 (بالتوقيت المحلي) كما يلي:</p> - -<pre class="brush: js">IPOdate.setTime(Date.parse('Aug 9, 1995'));</pre> - -<p>بعض الأمثلة الأخرى على تحليل سلاسل التاريخ غير القياسية:</p> - -<pre class="brush: js">Date.parse('Aug 9, 1995');</pre> - -<p>يٌعيد <code>807937200000</code> في المنطقة الزمنية GMT-0300، ويٌعيد قيم أخري في المناطق الزمنية الأخري، حيث أن السلسلة لا تحدد المناطق الزمنية وهي ليست بتنسيق ISO، وبالتالي فإن المنطقة الزمنية الافتراضية بدون تنسيق ISO هي المنطقة الزمنية المحلية الخاصة بالدولة الموجود بها. وتختلف من دولة إلي آخري.</p> - -<pre class="brush: js">Date.parse('Wed, 09 Aug 1995 00:00:00 GMT');</pre> - -<p>يٌعيد <code>807926400000</code> بغض النظر عن المنطقة الزمنية المحلية مثل GMT (UTC).</p> - -<pre class="brush: js">Date.parse('Wed, 09 Aug 1995 00:00:00'); -</pre> - -<p>يٌعيد <code>807937200000</code> في المنطقة الزمنية GMT-0300، ويٌعيد قيم أخري في المناطق الزمنية الأخري، حيث أن السلسلة لا تحدد المناطق الزمنية وهي ليست بتنسيق ISO، وبالتالي فإن المنطقة الزمنية الافتراضية بدون تنسيق ISO هي المنطقة الزمنية المحلية الخاصة بالدولة الموجود بها. وتختلف من دولة إلي آخري.</p> - -<pre class="brush: js">Date.parse('Thu, 01 Jan 1970 00:00:00 GMT'); -</pre> - -<p>يٌعيد <code>0</code> بغض النظر عن المنطقة الزمنية المحلية مثل GMT (UTC).</p> - -<pre class="brush: js">Date.parse('Thu, 01 Jan 1970 00:00:00'); -</pre> - -<p>يٌعيد <code>14400000</code> في المنطقة الزمنية GMT-0400، ويٌعيد قيم أخري في المناطق الزمنية الأخري، حيث أن السلسلة لا تحدد المناطق الزمنية وهي ليست بتنسيق ISO، وبالتالي فإن المنطقة الزمنية الافتراضية بدون تنسيق ISO هي المنطقة الزمنية المحلية الخاصة بالدولة الموجود بها. وتختلف من دولة إلي آخري.</p> - -<pre class="brush: js">Date.parse('Thu, 01 Jan 1970 00:00:00 GMT-0400'); -</pre> - -<p>يٌعيد <code>14400000</code> بغض النظر عن المنطقة الزمنية المحلية مثل GMT (UTC).</p> - -<h2 id="الخصائص">الخصائص</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - <tr> - <td>{{SpecName('ES1')}}</td> - <td>{{Spec2('ES1')}}</td> - <td>Initial definition. Implemented in JavaScript 1.0.</td> - </tr> - <tr> - <td>{{SpecName('ES5.1', '#sec-15.9.4.2', 'Date.parse')}}</td> - <td>{{Spec2('ES5.1')}}</td> - <td>Simplified ISO 8601 format added.</td> - </tr> - <tr> - <td>{{SpecName('ES6', '#sec-date.parse', 'Date.parse')}}</td> - <td>{{Spec2('ES6')}}</td> - <td> </td> - </tr> - <tr> - <td>{{SpecName('ESDraft', '#sec-date.parse', 'Date.parse')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td> </td> - </tr> - </tbody> -</table> - -<h2 id="دعم_المتصفحات">دعم المتصفحات</h2> - -<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> - -<p>{{Compat("javascript.builtins.Date.parse")}}</p> - -<h2 id="ملاحظات_التوافق">ملاحظات التوافق</h2> - -<ul> - <li>Firefox 49 {{geckoRelease(49)}} changed the parsing of 2-digit years to be aligned with the Google Chrome browser instead of Internet Explorer. Now, 2-digit years that are less than <code>50</code> are parsed as 21st century years. For example, <code>04/16/17</code>, previously parsed as April 16, 1917, will be April 16, 2017 now. To avoid any interoperability issues or ambiguous years, it is recommended to use the ISO 8601 format like "2017-04-16" ({{bug(1265136)}}).</li> -</ul> - -<h2 id="اقرأ_أيضًا">اقرأ أيضًا</h2> - -<ul> - <li>{{jsxref("Date.UTC()")}}</li> -</ul> |