From d9e9adb5f80a819fe46349bcf6d1faec734b09cd Mon Sep 17 00:00:00 2001 From: Irvin Date: Wed, 16 Feb 2022 02:07:31 +0800 Subject: remove span tag in zh-CN --- .../reference/global_objects/date/date/index.html | 2 +- .../global_objects/date/getdate/index.html | 8 ++++---- .../global_objects/date/getday/index.html | 8 ++++---- .../global_objects/date/gethours/index.html | 6 +++--- .../global_objects/date/getmilliseconds/index.html | 6 +++--- .../global_objects/date/getminutes/index.html | 4 ++-- .../global_objects/date/getseconds/index.html | 4 ++-- .../reference/global_objects/date/now/index.html | 4 ++-- .../reference/global_objects/date/parse/index.html | 24 +++++++++++----------- .../global_objects/date/setfullyear/index.html | 4 ++-- .../global_objects/date/sethours/index.html | 2 +- .../global_objects/date/setutcfullyear/index.html | 2 +- .../date/tolocaledatestring/index.html | 2 +- .../global_objects/date/tolocalestring/index.html | 4 ++-- .../date/tolocaletimestring/index.html | 4 ++-- 15 files changed, 42 insertions(+), 42 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/date') diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/date/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/date/index.html index 2b1e77c4b3..f97d377482 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/date/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/date/index.html @@ -5,7 +5,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/Date ---
{{JSRef}}
-

Creates a JavaScript Date instance that represents a single moment in time in a platform-independent format. Date objects contain a Number that represents milliseconds since 1 January 1970 UTC.

+

Creates a JavaScript Date instance that represents a single moment in time in a platform-independent format. Date objects contain a Number that represents milliseconds since 1 January 1970 UTC.

{{EmbedInteractiveExample("pages/js/date-constructor.html")}}
diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getdate/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getdate/index.html index 17608a744f..4bbfc8ad23 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getdate/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getdate/index.html @@ -27,12 +27,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDate

例子: 使用getDate()方法

-

下面第二条语句将值25赋给 day 变量,该值基于日期对象 Xmax95的值。

+

下面第二条语句将值25赋给 day 变量,该值基于日期对象 Xmax95的值。

-
var Xmas95 = new Date("December 25, 1995 23:15:00");
-var day = Xmas95.getDate();
+
var Xmas95 = new Date("December 25, 1995 23:15:00");
+var day = Xmas95.getDate();
 
-alert(day); // 25
+alert(day); // 25

规范

diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getday/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getday/index.html index 86badcff49..e9b18b852e 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getday/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getday/index.html @@ -26,10 +26,10 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDay

下面第二条语句,基于{{jsxref("Date")}}对象 Xmas95 的值,把 1 赋值给 weekday。也就是说1995年12月25日是星期一。

-
var Xmas95 = new Date("December 25, 1995 23:15:30");
-var weekday = Xmas95.getDay();
+
var Xmas95 = new Date("December 25, 1995 23:15:30");
+var weekday = Xmas95.getDay();
 
-console.log(weekday); // 1
+console.log(weekday); // 1

注意:如果需要,可以使用{{jsxref("DateTimeFormat", "Intl.DateTimeFormat")}}与一个额外的options 参数,从而返回这天的全称(如"Monday").使用此方法,结果会更加国际化:

@@ -51,7 +51,7 @@ console.log(new Intl.DateTimeFormat('de-DE', options).format(Xmas95)); 注解 - {{SpecName('ESDraft', '#sec-date.prototype.getday', 'Date.prototype.getDay')}} + {{SpecName('ESDraft', '#sec-date.prototype.getday', 'Date.prototype.getDay')}}   {{Spec2('ESDraft')}}   diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/gethours/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/gethours/index.html index c15bc0f6cf..eb8ad854e1 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/gethours/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/gethours/index.html @@ -29,10 +29,10 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getHours

下面第二条语句,基于日期对象 Xmas95 的值,把 23 赋值给了变量 hours。

-
var Xmas95 = new Date("December 25, 1995 23:15:00");
-var hours = Xmas95.getHours();
+
var Xmas95 = new Date("December 25, 1995 23:15:00");
+var hours = Xmas95.getHours();
 
-alert(hours); // 23
+alert(hours); // 23

规范

diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getmilliseconds/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getmilliseconds/index.html index db20141cc4..15d556779d 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getmilliseconds/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getmilliseconds/index.html @@ -29,9 +29,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds

下例中,将当前时间的毫秒数赋值给变量 ms

-
var ms;
-Today = new Date();
-ms = Today.getMilliseconds();
+
var ms;
+Today = new Date();
+ms = Today.getMilliseconds();

规范

diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getminutes/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getminutes/index.html index 5bcbcfc724..7a1fd0f433 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getminutes/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getminutes/index.html @@ -27,8 +27,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getMinutes

下例中,第二行语句运行过后,变量 minutes 的值为15,也就是说 Xmas95 这个日期对象的值为某时15分某秒。

-
var Xmas95 = new Date("December 25, 1995 23:15:00");
-var minutes = Xmas95.getMinutes();
+
var Xmas95 = new Date("December 25, 1995 23:15:00");
+var minutes = Xmas95.getMinutes();

规范

diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getseconds/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getseconds/index.html index 83a899886e..457f166047 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getseconds/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getseconds/index.html @@ -29,8 +29,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getSeconds

下面第二条语句,基于日期对象 Xmas95 的值,把 30 赋值给变量 secs

-
var Xmas95 = new Date("December 25, 1995 23:15:30");
-var secs = Xmas95.getSeconds();
+
var Xmas95 = new Date("December 25, 1995 23:15:30");
+var secs = Xmas95.getSeconds();
 
diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/now/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/now/index.html index b7153612a2..fd0c8dd482 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/now/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/now/index.html @@ -30,9 +30,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/now

因为 now() 是 {{jsxref("Date")}} 的一个静态函数,所以必须以 Date.now() 的形式来使用。

-

时间精度被降低

+

时间精度被降低

-

为了提供针对定时攻击和指纹追踪的保护,Date.now() 的精度可能会根据浏览器的高级设置项目而被取整。
+

为了提供针对定时攻击和指纹追踪的保护,Date.now() 的精度可能会根据浏览器的高级设置项目而被取整。
在 Firefox 中,默认启用 privacy.reduceTimerPrecision 设置项,在 Firefox 59 中,默认被取整至 20 微秒;在 Firefox 60 中,则被取整至 2 毫秒。

// reduced time precision (2ms) in Firefox 60
diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html
index 701f6fc103..9646b069da 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html
@@ -52,7 +52,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse
 
 

由于在解析日期字符串时存在偏差会导致结果不一致,因此推荐始终手动解析日期字符串,特别是不同的ECMAScript实现会把诸如“2015-10-12 12:00:00”的字符串解析为NaN,UTC或者本地时间。

-

ECMAScript 5 ISO-8601 日期格式支持

+

ECMAScript 5 ISO-8601 日期格式支持

另外,日期时间字符串也可以使用 ISO 8601 格式。例如,"2011-10-10" (仅日期)或 "2011-10-10T14:48:00" (日期和时间)能够作为参数被传递和解析。 如果参数字符串只包含日期格式,那么将会使用UTC时区来解析该参数。而如果是ISO 8601 格式中规定的时间加日期的格式,则将会被作为本地时区处理。

@@ -70,26 +70,26 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse

但是, 在如 ECMA-262 规范中定义的情况,如果因为无效值而导致日期字符串不能被识别为 ISO 格式时,根据浏览器和给定的值不同,返回值可以是,也可以不是 {{jsxref("NaN")}} 。比如:

-
// 包含无效值的非 ISO 格式字符串
-new Date('23/25/2014');
+
// 包含无效值的非 ISO 格式字符串
+new Date('23/25/2014');

在 Firefox 30 中会被识别为本地时区的2015年12月25日,而在 Safari 7 中则是无效日期。但是,如果字符串被识别为 ISO 格式并且包含无效值,则在所有遵循 ES5 或者更新标准的浏览器中都会返回 {{jsxref("NaN")}} 。

-
// 包含无效值的 ISO 格式字符串
-new Date('2014-25-23').toISOString();
-// 在所有遵循 ES5的浏览器中返回 "RangeError: invalid date"
+
// 包含无效值的 ISO 格式字符串
+new Date('2014-25-23').toISOString();
+// 在所有遵循 ES5的浏览器中返回 "RangeError: invalid date"

SpiderMonkey 的引擎策略可以在 jsdate.cpp  中找到。字符串 "10 06 2014"  可以作为非 ISO 格式字符串使用自定义处理方式的例子。参见这篇关于解析如何进行的粗略纲要

-
new Date('10 06 2014');
+
new Date('10 06 2014');

将会被解析为本地时间 2014年10月6日,而不是6月10日。另一个例子

-
new Date('foo-bar 2014').toString();
-// 返回: "Invalid Date"
+
new Date('foo-bar 2014').toString();
+// 返回: "Invalid Date"
 
-Date.parse('foo-bar 2014');
-// 返回: NaN
+Date.parse('foo-bar 2014'); +// 返回: NaN

例子

@@ -97,7 +97,7 @@ Date.parse如果 IPOdate 是一个已经存在的 {{jsxref("Date")}} 对象,则可以把其设置为本地时间 1995年8月9日。如下:

-
IPOdate.setTime(Date.parse('Aug 9, 1995'));
+
IPOdate.setTime(Date.parse('Aug 9, 1995'));

其他一些解析非标准格式日期的例子:

diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/setfullyear/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/setfullyear/index.html index 72a0583a2d..ad8ffc0c33 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/setfullyear/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/setfullyear/index.html @@ -36,8 +36,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setFullYear

例子:使用setFullYear方法

-
var theBigDay = new Date();
-theBigDay.setFullYear(1997);
+
var theBigDay = new Date();
+theBigDay.setFullYear(1997);

规范

diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/sethours/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/sethours/index.html index 5b0315f92d..43786dadd9 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/sethours/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/sethours/index.html @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setHours

语法

-
dateObj.setHours(hoursValue[, minutesValue[, secondsValue[, msValue]]])
+
dateObj.setHours(hoursValue[, minutesValue[, secondsValue[, msValue]]])
 

JavaScript 1.3版本之前

diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/setutcfullyear/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/setutcfullyear/index.html index 9d448b59df..fd83af1c4e 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/setutcfullyear/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/setutcfullyear/index.html @@ -84,7 +84,7 @@ theBigDay.setUTCFullYear(1997);

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

-

相关连接

+

相关连接