Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

日期 #76

Merged
merged 28 commits into from May 6, 2018
Merged

日期 #76

merged 28 commits into from May 6, 2018

Conversation

allenlongbaobao
Copy link
Contributor

翻译完成。
resolve #66

@allenlongbaobao
Copy link
Contributor Author

@leviding

@Starriers
Copy link
Contributor

@leviding 校对认领

@leviding
Copy link
Member

leviding commented May 5, 2018

@Starriers ok

@jasonxia23
Copy link

@leviding 认领校对

@leviding
Copy link
Member

leviding commented May 5, 2018

@jasonxia23 ok

Copy link
Contributor

@Starriers Starriers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Show it using `alert`.
使用 `alert` 展示结果。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

展示 感觉不如 显示 读起来比较好 。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成输出结果呢,会不会好点

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改为显示


To implement it let's clone the date, like this:
要实现这一点,我们可以赋值这个日期,就像这样:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

赋值 =》 拷贝 感觉代码 不像是赋值

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

译者的意思是复制吧,我觉得复制感觉也不错

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对,是复制,错字了。

@@ -2,13 +2,13 @@ importance: 4

---

# Which day of month was many days ago?
# 多天之前是哪一天?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多天之前 ??

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多天之前是哪一天?
=>
很多天前是这个月的哪一天?


Should also work over months/years reliably:
跨越月、年应该也是正确输出:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

越 去掉


- `year` -- four-digits year, for instance 2012.
- `month` -- month, from 0 to 11.
- `year` -- 四位数的年份,比如 2012。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

破折号 用中文的


`new Date(datestring)`
: If there is a single argument, and it's a string, then it is parsed with the `Date.parse` algorithm (see below).
:如果只有一个参数,并且是字符串,那么该参数会通过 `Date.parse` 算法解析 (下面会提到)。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

解析后多了空格


[getMonth()](mdn:js/Date/getMonth)
: Get the month, **from 0 to 11**.
: 获取月份 **从 0 11**.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

月份后多了空格
句号 中文


The *autocorrection* is a very handy feature of `Date` objects. We can set out-of-range values, and it will auto-adjust itself.
**自动校准** 是 `Date` 对象一个非常方便的特性。我们可以设置超范围的数值,它会自动校准。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是 前面不要空格

@@ -347,75 +347,75 @@ alert( 'Total time for diffSubtract: ' + time1 );
alert( 'Total time for diffGetTime: ' + time2 );
```

Modern JavaScript engines start applying advanced optimizations only to "hot code" that executes many times (no need to optimize rarely executed things). So, in the example above, first executions are not well-optimized. We may want to add a heat-up run:
现代的 JavaScript 引擎的先进优化策略只对执行很多次的「高温代码」有效(对于执行很少次数的代码没有必要优化)。因此,以上的例子中,第一部分不会被优化,我们可能需要增加一个升温步骤:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hot code 翻译成这个不太好 还是不要翻译了吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯,同意

for (let i = 0; i < 10; i++) {
time1 += bench(diffSubtract);
time2 += bench(diffGetTime);
}
```

```warn header="Be careful doing microbenchmarking"
Modern JavaScript engines perform many optimizations. They may tweak results of "artificial tests" compared to "normal usage", especially when we benchmark something very small. So if you seriously want to understand performance, then please study how the JavaScript engine works. And then you probably won't need microbenchmarks at all.
```warn header="做微度量时请小心"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

空格

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

哪里的空格?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

中英文啊
天啊 程序员不要睡觉的么 周末你还加班

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这儿不需要空格哈,没有中英文挨着的啊

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂 有道理

Copy link

@jasonxia23 jasonxia23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Show it using `alert`.
使用 `alert` 展示结果。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成输出结果呢,会不会好点

@@ -3,7 +3,7 @@ function getLocalDay(date) {

let day = date.getDay();

if (day == 0) { // 0 becomes 7
 if (day == 0) { // 0,改为7

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0,改为7
=>
0 变成 7


To implement it let's clone the date, like this:
要实现这一点,我们可以赋值这个日期,就像这样:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

译者的意思是复制吧,我觉得复制感觉也不错

@@ -2,13 +2,13 @@ importance: 4

---

# Which day of month was many days ago?
# 多天之前是哪一天?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多天之前是哪一天?
=>
很多天前是这个月的哪一天?


Should also work over months/years reliably:
跨越月、年应该也是正确输出:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该也是
=>
也应该

// add leading zeroes to single-digit day/month/hours/minutes
 // 格式化日期
 // 在单个数值之前加 0 日/月/小时/分钟
 // 在单个数值之前加 0 日/月/小时/分钟

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这行重复

@@ -2,16 +2,16 @@ importance: 4

---

# Format the relative date
# 格式化日期

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

格式化日期
=>
格式化相对日期

Copy link
Member

@leviding leviding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

很赞

@leviding leviding merged commit bfca9f3 into javascript-tutorial:zh-hans May 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants