doulu5109 2019-08-06 07:31
浏览 63
已采纳

我将日期保存在JSON中,当我重新加载它时,它看起来几乎是相同的……“ m = + 2.58”是什么? [重复]

This question already has an answer here:

I'm writing a test in Golang which verifies that a journal on disk is properly managed. When I look at the file I see the correct date, but when I look at the date in the test and the date I reload from JSON, they look different:

Timestamp I got with time.Now():

2019-08-06 00:17:46.033527441 -0700 PDT m=+2.582718548

Timestamp I reloaded from the JSON:

2019-08-06 00:17:46.033527441 -0700 PDT

If I change the date to UTC(), it all works as expected (i.e. start with time.Now().UTC()).

I understand that the location is different, I'm just not too sure what the m=... parameter stands for and why would it not be present in the date I reloaded from JSON since it is the exact same date.

So... What is that field?

</div>
  • 写回答

1条回答 默认 最新

  • dongsilu2237 2019-08-06 07:42
    关注
    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.

    Reference


    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 kali环境运行volatility分析android内存文件,缺profile
  • ¥15 写uniapp时遇到的问题
  • ¥15 vs 2008 安装遇到问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码
  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题
  • ¥20 MATLAB绘制两隐函数曲面的交线