我在 JSON 中保存了一个日期,当我重新加载它时,它看起来几乎一样......那个 `m=+2.58` 是什么?
I save a date in a JSON, when I reload it, it looks nearly the same... What is that `m=+2.58`?
我正在用 Golang 编写测试,以验证磁盘上的日志是否得到妥善管理。当我查看文件时,我看到了正确的日期,但是当我查看测试中的日期和我从 JSON 重新加载的日期时,它们看起来不同:
我得到的时间戳 time.Now()
:
2019-08-06 00:17:46.033527441 -0700 PDT m=+2.582718548
我从 JSON 重新加载的时间戳:
2019-08-06 00:17:46.033527441 -0700 PDT
如果我将日期更改为 UTC()
,一切都会按预期进行(即从 time.Now().UTC()
开始)。
我知道位置不同,我只是不太确定 m=...
参数代表什么以及为什么它不会出现在我从 JSON 重新加载的日期,因为它是完全相同的日期。
那么...那个字段是什么?
fmt.Println(time.Now().String())
String returns the time formatted using the format string "2006-01-02
15:04:05.999999999 -0700 MST" If the time has a monotonic clock
reading, the returned string includes a final field "m=±",
where value is the monotonic clock reading formatted as a decimal
number of seconds. The returned string is meant for debugging; for a
stable serialized representation, use t.MarshalText, t.MarshalBinary,
or t.Format with an explicit format string.
Monotonic Clocks
Operating systems provide both a “wall clock,” which
is subject to changes for clock synchronization, and a “monotonic
clock,” which is not. The general rule is that the wall clock is for
telling time and the monotonic clock is for measuring time. Rather
than split the API, in this package the Time returned by time.Now
contains both a wall clock reading and a monotonic clock reading;
later time-telling operations use the wall clock reading, but later
time-measuring operations, specifically comparisons and subtractions,
use the monotonic clock reading.
我正在用 Golang 编写测试,以验证磁盘上的日志是否得到妥善管理。当我查看文件时,我看到了正确的日期,但是当我查看测试中的日期和我从 JSON 重新加载的日期时,它们看起来不同:
我得到的时间戳 time.Now()
:
2019-08-06 00:17:46.033527441 -0700 PDT m=+2.582718548
我从 JSON 重新加载的时间戳:
2019-08-06 00:17:46.033527441 -0700 PDT
如果我将日期更改为 UTC()
,一切都会按预期进行(即从 time.Now().UTC()
开始)。
我知道位置不同,我只是不太确定 m=...
参数代表什么以及为什么它不会出现在我从 JSON 重新加载的日期,因为它是完全相同的日期。
那么...那个字段是什么?
fmt.Println(time.Now().String())
String returns the time formatted using the format string "2006-01-02 15:04:05.999999999 -0700 MST" If the time has a monotonic clock reading, the returned string includes a final field "m=±", where value is the monotonic clock reading formatted as a decimal number of seconds. The returned string is meant for debugging; for a stable serialized representation, use t.MarshalText, t.MarshalBinary, or t.Format with an explicit format string.
Monotonic Clocks
Operating systems provide both a “wall clock,” which is subject to changes for clock synchronization, and a “monotonic clock,” which is not. The general rule is that the wall clock is for telling time and the monotonic clock is for measuring time. Rather than split the API, in this package the Time returned by time.Now contains both a wall clock reading and a monotonic clock reading; later time-telling operations use the wall clock reading, but later time-measuring operations, specifically comparisons and subtractions, use the monotonic clock reading.