Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass Core.Zone.local to Time.to_sec_string in log_entry #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stu-art
Copy link

@stu-art stu-art commented Mar 1, 2015

I received

Error: This expression has type zone:Core.Zone.t -> bytes                                        
       but an expression was expected of type bytes  

When entering the log_entry definition into utop. After some discussion in the #ocaml freenode room, this fixes the issue.

@khanjehanzeb
Copy link

Can anyone explain the reason why we have to pass Core.zone.local ?

@agarwal
Copy link

agarwal commented Aug 15, 2015

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.

@khanjehanzeb
Copy link

so in the book there was a typo in the example ?

@agarwal
Copy link

agarwal commented Aug 15, 2015

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.

@OldPanda
Copy link

Here's a SO answer explaining this https://stackoverflow.com/a/34224843/2191173

@sharno
Copy link

sharno commented Sep 30, 2017

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

@teohhanhui
Copy link

Or use:

Time.to_sec_string ~zone:Time.Zone.utc time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants