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 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置