28 October 2019

Time.time andygrunwald/go-jira

A Time represents an instant in time with nanosecond precision.
Time được biểu diễn thời gian ngay lập tức với độ chính xác nanosecond
Programs using times should typically store and pass them as values, not pointers. That is, time variables and struct fields should be of type time.Time, not *time.Time.
Chương trình sử dụng time nên được lưu trữ và pass chúng như là value, không phải con trỏ. Do đó, biến time và struct fields nên là type time.Time, không phải *time.Time.
A Time value can be used by multiple goroutines simultaneously except that the methods GobDecode, UnmarshalBinary, UnmarshalJSON and UnmarshalText are not concurrency-safe.
Time value có thể được sử dụng bởi nhiều goroutine đồng thời ngoại trừ rằng methods GobDecode, UnmarshalBinary, UnmarshalJSON và UnmarshalText là không an toàn khi concurrency.
Time instants can be compared using the Before, After, and Equal methods. The Sub method subtracts two instants, producing a Duration. The Add method adds a Time and a Duration, producing a Time.
Time instants có thể được so sánh sử dụng Before, After, Equal methods. Sub methods trừ 2 instants tạo ra Durations. Add methods add 2 Time và Durations, tạo ra time.
The zero value of type Time is January 1, year 1, 00:00:00.000000000 UTC. As this time is unlikely to come up in practice, the IsZero method gives a simple way of detecting a time that has not been initialized explicitly.
Giá trị 0 của Time là January 1, year 1, 00:00:00.000000000 UTC. Ở thời gian này không theo thực tế, IsZero method đưa ra một cách đơn giản phát hiện time mà không được khởi tạo rõ ràng.
Each Time has associated with it a Location, consulted when computing the presentation form of the time, such as in the Format, Hour, and Year methods. The methods Local, UTC, and In return a Time with a specific location. Changing the location in this way changes only the presentation; it does not change the instant in time being denoted and therefore does not affect the computations described in earlier paragraphs.
Từng time có quan hệ với Location, tham khảo khi tính toán form hiển thị của time, như là Format, Hour, Years methos. Methods Local, UTC và In trả lại time với location nhất định. Thay đổi location theo cách này chỉ thay đổi cách hiển thị, nó không thay đổi instant của time đang được chỉ rõ, và do đó không ảnh hưởng tới tính toán được mô tả ở các đoạn trước.
Representations of a Time value saved by the GobEncode, MarshalBinary, MarshalJSON, and MarshalText methods store the Time.Location’s offset, but not the location name. They therefore lose information about Daylight Saving Time.
Biểu thị của Time value được lưu bởi methods GobEncode, MarshalBinary, MarshalJSON, and MarshalText lưu trữ offset Time.Location, nhưng không phải location name. Chúng do đó thiếu thông tin về Daylight Saving Time.
In addition to the required “wall clock” reading, a Time may contain an optional reading of the current process’s monotonic clock, to provide additional precision for comparison or subtraction. See the “Monotonic Clocks” section in the package documentation for details.
Thêm vào yêu cầu đọc wall clock, Time có thể bao gồm các optional reading của current process monotonic clock, để cung cấp các độ chính xác thêm để so sánh và tính toán. Xem thêm phần “Monotonic Clocks” trong package document để biết chi tiết.
Note that the Go == operator compares not just the time instant but also the Location and the monotonic clock reading. Therefore, Time values should not be used as map or database keys without first guaranteeing that the identical Location has been set for all values, which can be achieved through use of the UTC or Local method, and that the monotonic clock reading has been stripped by setting t = t.Round(0). In general, prefer t.Equal(u) to t == u, since t.Equal uses the most accurate comparison available and correctly handles the case when only one of its arguments has a monotonic clock reading.
Chú ý rằng Go == operator so sánh không chỉ time instant mà Location và monotonic clock reading. Do đó, Time value không nên được sử dụng như là map hoặc database key mà không đảm bảo rằng Location duy nhất đã được set cho tất cả value, mà có thể đạt được thông qua UTC hoặc local method, và rằng monotonic clock reading đã được lược bỏ bằng cách t = t.Round(0). Thông thường, thích cách này hơn prefer t.Equal(u) so với t == u vì t.Equal sử dụng so sánh chính xác nhất so với các loại còn lại và xử lý một cách chính xác trường hợp khi chỉ một tham số của nó có monotonic clock reading.