pass Core.Zone.local to Time.to_sec_string in log_entry#33
pass Core.Zone.local to Time.to_sec_string in log_entry#33stu-art wants to merge 1 commit intorealworldocaml:masterfrom
Conversation
|
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: so passing |
|
Or use: Time.to_sec_string ~zone:Time.Zone.utc time |
I received
When entering the
log_entrydefinition intoutop. After some discussion in the #ocaml freenode room, this fixes the issue.