Open stu-art opened 9 years ago
Can anyone explain the reason why we have to pass Core.zone.local ?
Can anyone explain the reason why we have to pass Core.zone.local ?
The resulting string will differ depending on the timezone, so what timezone should be assumed if you didn't have to pass this argument. You can't just assume local timezone because maybe you're generating a webpage and want to show the string in the user's timezone, rather than that of the server.
so in the book there was a typo in the example ?
I see what you mean. The API of Core has changed since the book was published. I just checked the older version of to_sec_string, and indeed it doesn't take a timezone argument. That's not very flexible, so I guess they improved the function since then.
Here's a SO answer explaining this https://stackoverflow.com/a/34224843/2191173
The API of Core has changed again: https://ocaml.janestreet.com/ocaml-core/v0.9/doc/core/Core__/Core_time_float/Zone/index.html
val local : t Core__.Import.Lazy.t
so passing local
is not a solution for version 0.9 of Core
I think it's better just to use to_string
instead
Or use:
Time.to_sec_string ~zone:Time.Zone.utc time
I received
When entering the
log_entry
definition intoutop
. After some discussion in the #ocaml freenode room, this fixes the issue.